Data type mismatch

teric2

Registered User.
Local time
Today, 07:54
Joined
Feb 20, 2010
Messages
32
Hello all!
Can someone tell me why I would get "data type mismatch" error for this string and what I need to do to correct it.
Trying to use it as a row source for a combo box in Access 2010


strRowSource = "SELECT time FROM [silo changes] WHERE [date]= """ & Me!Combo2 & """"

Thanks!
 
Try;
Code:
strRowSource = "SELECT time FROM [silo changes] WHERE [date]= #" & Me!Combo2 & "#"
As dates need to be enclosed in hash marks rather than quotes.

Also you appear to be using date (which is a reserved word) as a field name, this could cause you grief in the future if it is not already doing so.

If you were dealing with a string value your argument should look like;
Code:
strRowSource = "SELECT time FROM [silo changes] WHERE [date]= [B][COLOR="Red"]'[/COLOR][/B]" & Me!Combo2 & "[B][COLOR="Red"]'[/COLOR][/B]"
 
Excellent! Your first example worked for me and I will change the name of that field from Date to something else.

Thank you very much!
 
You need to be careful when changing control and object names in your DB, that you also change all reference to that object/control.
 

Users who are viewing this thread

Back
Top Bottom