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
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) )
Re: Data type mismatch in criteria expression???
Since when do you use Database-Fieldnames in single-quotes? :confused:
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))