By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

Data Type mismatch?!

P: 48
The below code throws the error: "Data type mismatch in criteria expression"
Searching online didn't seem to offer me a solution.

Expand|Select|Wrap|Line Numbers
  1. Public Sub update_by_EDD(myDate As Date, myMR As String)
  2.      Dim rs As Object
  3.  
  4.      Set rs = Me.Recordset.Clone
  5.      ' strCriteria = "([myString] = '" & myMR & "')"
  6.      strCriteria = "([EDD] = '" & myDate & "')"
  7.      rs.FindFirst (strCriteria)
  8.  
  9. End Sub
Now, if I use the commented expression instead of the Date counterpart, it doesn't throw the error. For some reason, the Date expression is not well liked.

[EDD] is defined as a Date/Time in the corresponding Table. If I define it in the function as "myDate as String", the error remains. So, assuming that myDate is actually being read as a date due to the definition, how do I check [EDD]? Is there a handy way to debug data types?

Thank you in advance.
Aug 6 '07 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,392
Replace the single quotes ( ' ) with pound signs ( # )
Aug 6 '07 #2

Stang02GT
Expert 100+
P: 1,208
Expand|Select|Wrap|Line Numbers
  1.      ' strCriteria = "([myString] = '" & myMR & "')"
  2.  
  3. End Sub
Try taking the single quotes out. Just use the double quotes. I think your error has to do with what data type myMR is.
Aug 6 '07 #3

P: 48
Thanky ou rabbit, worked like a charm.

Thank you too, stang, I appreciate the efforts of anyone willing to help. =)
Aug 6 '07 #4

Stang02GT
Expert 100+
P: 1,208
Your welcome. I had the same error before and my solution had to do with how i was using the quotes. Good to see that you got your answer :)
Aug 6 '07 #5

Rabbit
Expert Mod 10K+
P: 12,392
Thanky ou rabbit, worked like a charm.

Thank you too, stang, I appreciate the efforts of anyone willing to help. =)
EDD is a date. Anything in quotes is considered text. Anything out of quotes is considered either a number or a variable. Anything in pound signs is considered a date.
Aug 6 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.