Results 1 to 3 of 3

Thread: Data type mismatch in criteria expression???

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2009
    Posts
    876

    Data type mismatch in criteria expression???

    Hi guys I keep getting an error :


    Run-time error '3464':

    Data type mismatch in criteria expression



    the code that gets highlighted is the following



    Set rs = db.OpenRecordset("SELECT * FROM `schedule` WHERE `theid` = " & "'" & Form9.ListView1.SelectedItem.SubItems(4) & "'")




    any ideas?

    Thanks

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Data type mismatch in criteria expression???

    As a guess I would say that your ID field is a numeric data type in the db and you are passing data as though it were a string causing a type mismatch.

    If it is a numeric field then you need to remove the single quotes from you select statement like so
    Code:
    Set rs = db.OpenRecordset("SELECT * FROM `schedule` WHERE `theid` = " &  Form9.ListView1.SelectedItem.SubItems(4) )

  3. #3
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,268

    Re: Data type mismatch in criteria expression???

    Since when do you use Database-Fieldnames in single-quotes?

    And as for the Type Mismatch: If SubItems(4) is Numeric, i would force-change it, because SubItems is per se a string, independent of its contents.
    Code:
    ..... WHERE theid = " & CLng(Form9.ListView1.SelectedItem.SubItems(4))
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

Posting Permissions

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



Click Here to Expand Forum to Full Width