DLookup Data Mismatch

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
 
F

fredg

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top