Dlookup syntax with 3 variables as criteria (1 Viewer)

Drand

Registered User.
Local time
Today, 12:28
Joined
Jun 8, 2019
Messages
179
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

..forever waiting... waiting for jellybean!
Local time
Today, 10:28
Joined
May 7, 2009
Messages
19,229
Code:
Dlookup ("StockNumber","TblStock","Supplier ='" &  Supplier & "' and StockItem = '" & StockItem & "' and DateAdded =#" & Format(MyLatestDate, "mm\/dd\/yyyy") & "#")
 

Drand

Registered User.
Local time
Today, 12:28
Joined
Jun 8, 2019
Messages
179
Thanks again.
works a treat!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:28
Joined
May 7, 2009
Messages
19,229
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, 04:28
Joined
Aug 11, 2003
Messages
11,695
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