Data Type mismatch?!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • isoquin
    New Member
    • Jul 2007
    • 48

    Data Type mismatch?!

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

    Code:
    Public Sub update_by_EDD(myDate As Date, myMR As String)
         Dim rs As Object
         
         Set rs = Me.Recordset.Clone
         ' strCriteria = "([myString] = '" & myMR & "')"
         strCriteria = "([EDD] = '" & myDate & "')"
         rs.FindFirst (strCriteria)
        
    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.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Replace the single quotes ( ' ) with pound signs ( # )

    Comment

    • Stang02GT
      Recognized Expert Top Contributor
      • Jun 2007
      • 1206

      #3
      Originally posted by isoquin
      Code:
           ' strCriteria = "([myString] = '" & myMR & "')"
              
      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.

      Comment

      • isoquin
        New Member
        • Jul 2007
        • 48

        #4
        Thanky ou rabbit, worked like a charm.

        Thank you too, stang, I appreciate the efforts of anyone willing to help. =)

        Comment

        • Stang02GT
          Recognized Expert Top Contributor
          • Jun 2007
          • 1206

          #5
          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 :)

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Originally posted by isoquin
            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.

            Comment

            Working...