Data type mismatch in criteria expression

scoob8254

Registered User.
Local time
Today, 11:06
Joined
Mar 2, 2008
Messages
76
hello i get this error "Data type mismatch in criteria expression" with the code below

mySQL = "SELECT tblCatch.tblSpecies, tblCatch.tblBait, tblCatch.Image, tblCatch.tblReturned, tblCatch.tblSize"
mySQL = mySQL + " FROM tblCatch"
mySQL = mySQL + " WHERE (((tblCatch.tblTripId)=' & strTripid & '))"

ive tried changing the data types etc but cant get it to work, not sure what im doin wrong if anybody can help, i would have prefered to have it like this

mySQL = "SELECT tblCatch.tblSpecies, tblCatch.tblBait, tblCatch.Image, tblCatch.tblReturned, tblCatch.tblSize"
mySQL = mySQL + " FROM tblCatch"
mySQL = mySQL + " WHERE (((tblCatch.tblTripId)=[tblTripid]))"

but when i refer to the field directly in the criteria it always returns a result as if theirs no criteria, ie shows results with all tripids not just the one i wanted, this happened on a similar peice of code earlier in the form, but soon as i used a variable it worked fine..


their must be something fundamental im missing and need to understand,
any help appreciated
craig
 
If TripID is a number or date, use this code:

mySQL = "SELECT tblCatch.tblSpecies, tblCatch.tblBait, tblCatch.Image, tblCatch.tblReturned, tblCatch.tblSize"
mySQL = mySQL + " FROM tblCatch"
mySQL = mySQL + " WHERE tblCatch.tblTripId= " & strTripid

If TripID is a string, use this:

mySQL = "SELECT tblCatch.tblSpecies, tblCatch.tblBait, tblCatch.Image, tblCatch.tblReturned, tblCatch.tblSize"
mySQL = mySQL + " FROM tblCatch"
mySQL = mySQL + " WHERE tblCatch.tblTripId= '" & strTripid & "'"
 
thanks works a treat, seems obvious now i look at it but i never would have worked it out,

thanks for the help
craig
 

Users who are viewing this thread

Back
Top Bottom