Dlookup syntax with 3 variables as criteria (1 Viewer)

Drand

Registered User.
Local time
Today, 17:51
Joined
Jun 8, 2019
Messages
71
Hi Folks

Could someone please assist me with this. I cannot get the correct syntax!

MyLatestDate is Date
Supplier is String
StockItem = String

I am trying to:

Dlookup ("StockNumber","TblStock",Supplier = Supplier and StockItem = StockItem and DateAdded = MyLatestDate)

Many thanks
 

arnelgp

error reading drive A:
Local time
Today, 14:51
Joined
May 7, 2009
Messages
11,551
Code:
Dlookup ("StockNumber","TblStock","Supplier ='" &  Supplier & "' and StockItem = '" & StockItem & "' and DateAdded =#" & Format(MyLatestDate, "mm\/dd\/yyyy") & "#")
 

Drand

Registered User.
Local time
Today, 17:51
Joined
Jun 8, 2019
Messages
71
Thanks again.
works a treat!
 

arnelgp

error reading drive A:
Local time
Today, 14:51
Joined
May 7, 2009
Messages
11,551
just remember the syntax for the Criteria part:

if the criteria is string, enclosed in single quote,
if date, add hash (#) before and after.
use & to concatenate each criteria.
 

namliam

The Mailman - AWF VIP
Local time
Today, 07:51
Joined
Aug 11, 2003
Messages
11,696
Why use a DLookup at all, what is your goal?

D functions have their time and place, but 75% of the time there is a (much) better way of doing things.
 

Users who are viewing this thread

Top Bottom