DLookup Data Mismatch

  • Thread starter Thread starter Jani
  • Start date Start date
J

Jani

I'm getting a data mismatch error on the code below. I think it has something
to do with the date but not sure. I've checked the table and form and
everything is text excep the date fields are are both short date. Can anyone
see what I've doing incorrectly (silly question)? Thanks!

If Not IsNull(DLookup("[Plant]", "dbo_uBehvHistory", "[Auditor] = '" &
Me.cbo_Auditor & "' And [DateEntered] = '" & Me.DateEntered & "' And [Area] =
'" & Me.Area & "' And [SubArea] = '" & Me.SubArea & "'")) Then
 
I'm getting a data mismatch error on the code below. I think it has something
to do with the date but not sure. I've checked the table and form and
everything is text excep the date fields are are both short date. Can anyone
see what I've doing incorrectly (silly question)? Thanks!

If Not IsNull(DLookup("[Plant]", "dbo_uBehvHistory", "[Auditor] = '" &
Me.cbo_Auditor & "' And [DateEntered] = '" & Me.DateEntered & "' And [Area] =
'" & Me.Area & "' And [SubArea] = '" & Me.SubArea & "'")) Then

The date criteria (the [DateEntered] field is a Date datatype, not a
text datatype. isn't it?) must be enclosed with the date delimiter
symbol #.

If Not IsNull(DLookup("[Plant]", "dbo_uBehvHistory", "[Auditor] = '" &
Me.cbo_Auditor & "' And [DateEntered] = #" & Me.DateEntered & "# And
[Area] = '" & Me.Area & "' And [SubArea] = '" & Me.SubArea & "'"))
Then

I would assume from your code that all of the other fields are Text
datatype.
 
Back
Top