DLookup

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following statement below but it says there is a type mismatch can
some1 plz help me

If IsNull(DLookup("[Vitamol Ref]", "[New Part Notification]", "[New Part
Notification]![Vitamol Ref] ='" & Forms![sales_New Part Choice]![Vitamol Ref]
& "'") And ("[New Part Notification]![Date] = '" & Forms![sales_New Part
Choice]![Select] & "'")) Then


Cheers

Danny
 
Ignoring the type mismatch error for now, you've got unbalanced parentheses
in the statement: you haven't got an opening bracket to correspond to the
closing bracket after the first parameter. Your quotes are also incorrect:
AND needs to be within the quotes, not outside as you have it.

What you've got there assumes that both Vitamol Ref and Date are text fields
since you're enclosing the value in quotes. Assuming that Date is actually a
date field, you need to enclose the value in octothorpes (#). As well, you
need to ensure that the date is in mm/dd/yyyy format, regardless of what
your regional settings are

If IsNull(DLookup("[Vitamol Ref]", "[New Part Notification]", "[New
Part
Notification]![Vitamol Ref] ='" & Forms![sales_New Part Choice]![Vitamol
Ref]
& "' And [New Part Notification]![Date] = " & Format(Forms![sales_New Part
Choice]![Select], "\#mm\/dd\/yyyy\#"))) Then

BTW, Date isn't a good name to use for a field. Date is a reserved word, and
you should never use reserved words for your own purposes.
 
Back
Top