Dlookup syntax with 3 variables as criteria (1 Viewer)

Drand

Registered User.
Local time
Today, 23:33
Joined
Jun 8, 2019
Messages
65
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, 20:33
Joined
May 7, 2009
Messages
10,834
Code:
Dlookup ("StockNumber","TblStock","Supplier ='" &  Supplier & "' and StockItem = '" & StockItem & "' and DateAdded =#" & Format(MyLatestDate, "mm\/dd\/yyyy") & "#")
 

Drand

Registered User.
Local time
Today, 23:33
Joined
Jun 8, 2019
Messages
65
Thanks again.
works a treat!
 

arnelgp

error reading drive A:
Local time
Today, 20:33
Joined
May 7, 2009
Messages
10,834
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, 13:33
Joined
Aug 11, 2003
Messages
11,673
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