Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Posts
    2

    Unanswered: data type mismach while using openrecordset method

    I keep getting this "data mismatch in criteria expression" error.
    The code is simple and I have not been able to figure out the error.
    If someone could help me out, it would be great.
    TestQry = "SELECT [WC#] FROM [wc_Lookup_tbl] WHERE [WC#]=" & WC & ";"
    Set qdf1 = db1.CreateQueryDef("", TestQry)
    Set Val1 = qdf1.OpenRecordset()

  2. #2
    Join Date
    Nov 2002
    Location
    Wyoming
    Posts
    48
    Try:

    TestQry = "SELECT [WC#] FROM [wc_Lookup_tbl] WHERE [WC#]= '" & WC & "'"
    Cheers,
    Ken

  3. #3
    Join Date
    Apr 2004
    Posts
    2
    Thanks for the reply Ken. It works....
    However, In the Code:

    TestQry = "SELECT [WC#] FROM [wc_Lookup_tbl] WHERE [WC#]=" & WC & ";"
    Set qdf1 = db1.CreateQueryDef("", TestQry)
    Set Val1 = qdf1.OpenRecordset()

    I have Val1 Declared as a Recordset. This is giving me the "type mismatch error". If I declare Val1 as variant, the code works just fine.

    any suggestions?
    Vj





    Originally posted by KennyG
    Try:

    TestQry = "SELECT [WC#] FROM [wc_Lookup_tbl] WHERE [WC#]= '" & WC & "'"
    Last edited by vj1; 04-16-04 at 09:55.

  4. #4
    Join Date
    Nov 2002
    Location
    Wyoming
    Posts
    48
    This code worked for me. I was able to declare Val1 as a recordset; however, not until I changed the SELECT statement.

    TestQry = "SELECT [WC#] FROM [wc_Lookup_tbl] WHERE [WC#]= '" & WC & "'"
    Set qdf1 = db1.CreateQueryDef("", TestQry)
    Set Val1 = qdf1.OpenRecordset()


    HTH
    Cheers,
    Ken

Posting Permissions

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