Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2003
    Location
    Slovenia
    Posts
    18

    Question Unanswered: Recordset problem

    Helo!

    I have unusual problem.
    I use this code:



    Dim sql as String
    Dim db As Database
    Dim rs As Recordset

    Set db = CurrentDb

    sql = "Select products.* from products where products.products_id =" & Me.parameter

    Set rs = db.OpenRecordset(sql)



    I have a problem in opening recordset. If I test this SQL in a query is working with no problem. But when I try to open a recordset using this SQL I get "Type Mismatch" !!!!!

    How is this possible???

    Thank you for your answers!
    www.SloMusic.com

  2. #2
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Re: Recordset problem

    Originally posted by pinkpanter
    Helo!

    I have unusual problem.
    I use this code:



    Dim sql as String
    Dim db As Database
    Dim rs As Recordset

    Set db = CurrentDb

    sql = "Select products.* from products where products.products_id =" & Me.parameter

    Set rs = db.OpenRecordset(sql)



    I have a problem in opening recordset. If I test this SQL in a query is working with no problem. But when I try to open a recordset using this SQL I get "Type Mismatch" !!!!!

    How is this possible???

    Thank you for your answers!
    What is the data type of product_id?
    Gregg


    DAO, ADO, SQL, Automation and anything else I can pick up.

  3. #3
    Join Date
    Sep 2003
    Location
    Slovenia
    Posts
    18
    Data type is AutoNumber, me. parameter is Integer.

    But I don't think that is the problem. The SQL is working if I call it in a query - if I transfer SQL in a query and then run it...

    I don't know where to look anymore.
    www.SloMusic.com

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Try


    sql = "Select products.* from products where products.products_id =" & CLng (Me.parameter)

  5. #5
    Join Date
    Sep 2003
    Location
    Slovenia
    Posts
    18
    I did!! It's not working.

    I also thought that there is a problem with types - but if I get an error also with CLng function...
    There must be something else
    www.SloMusic.com

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by pinkpanter
    I did!! It's not working.

    I also thought that there is a problem with types - but if I get an error also with CLng function...
    There must be something else
    But you got a Type Mismatch error.

  7. #7
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445
    Originally posted by pinkpanter
    I did!! It's not working.

    I also thought that there is a problem with types - but if I get an error also with CLng function...
    There must be something else
    It may be a small thing but try adding a space after the "=" sign.


    sql = "Select products.* from products where products.products_id = " & Me.parameter
    Gregg


    DAO, ADO, SQL, Automation and anything else I can pick up.

  8. #8
    Join Date
    Mar 2004
    Posts
    118
    sql = "Select products.* from products where products.products_id = '" & CStr (Me.parameter) &"'"


    try that.

  9. #9
    Join Date
    Sep 2003
    Location
    Slovenia
    Posts
    18
    Thank you for the ideeas, but none is working.

    But I have some development...


    Set rs = db.OpenRecordset("SELECT * from products")


    is also not working!!! I'm still getting Type mismatch error...

    Is possible is got something with this:
    - program is version Access2000, but I'm now on Access2003
    - table is linked by ODBC (but I don't think that is a problem - it's also not working on normal table)

    Thank you!
    www.SloMusic.com

  10. #10
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    have you referenced the DAO library?

    ...and after that, change your declarations:
    Dim db As Database
    Dim rs As Recordset
    to:
    Dim db As dao.Database
    Dim rs As dao.Recordset


    izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •