Re: DLookup with multiple search criteria

K

Ken Snell

If DLookup doesn't find a value, it returns Null, so you may need to trap
that before you display your MsgBox. Otherwise, the MsgBox will always
display the text, with or without a value from the DLookup function.

But if that's not the problem that you're seeing, you may need to delimit
(with #) the value from the form for the date value:

result = DLookup("VendorName", "Vendor", "Vendor =" & "'" &
Forms!ExpenseHdrFrm!Vendor & "'" & " AND " & _
"Date =#" & Forms!ExpenseHdrFrm!Date & "#")
 
J

John Pritchard

Hi,

Thanks for the reply.

I tried delimiting the date with #'s but it made no
difference.

I was only using msgbox to see what DLookup was
returning ...

What I'm after is the equivalent of :-

select count(*)
from ExpenseHdr
where vandor = <value on my form>
and date = <value on my form>

The e.g. code was my attempt to get Dlookup to do this.

I can get the equivalent of :-

select count(*)
from ExpenseHdr
where vandor = <value on my form>

but I'm doing something wrong with the dlookup criteria
when trying to do the 'and Date ...' part in that the
Dlookup seems to ignore this part of my search criteria
completely.

Hope this clarifies my query!

Cheers

JP
 

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

Similar Threads

DLOOKUP - Multiple criteria 4
Global variable not working 8
DlookUp Help 6
help with Dlookup 2
DLookup 2007 2
Dlookup to find values not in table? 4
Using Max or DMax in DLookUp criteria? 1
DLookUp help 4

Top