DLookup Problem

mugman17

Registered User.
Local time
Today, 23:00
Joined
Nov 17, 2000
Messages
110
I am trying to create a DLookup with 2 criteria. This is what I have so far.

DLookUp("[PriceAmount]","tblPrice","Market=" & [Market] And "[PriceDate]=#" & #01/01/2004# & "#")

Its not working, so far it seems to pull out only the first record in the table. What am I doing wrong?

Thanks.
 
Try this:

DLookUp("[PriceAmount]","tblPrice","Market=" & [Market] " And [PriceDate]=#" & #01/01/2004# & "#")

Hope this helps,
 
mug,

Code:
Dim ThePrice As Currency
ThePrice = Nz(DLookUp("[PriceAmount]","tblPrice","[Market] = '" & Me.Market & "' And [PriceDate] = #01/01/2004#"), 0)

I'm assuming that Market is a control on your form and is a string.

Wayne
 
When it comes to strings, this is my personal preference.

Code:
Dim ThePrice As Currency
ThePrice = Nz(DLookUp("[PriceAmount]","tblPrice","[Market] = """ & Me.Market & """ And [PriceDate] = #01/01/2004#"), 0)

Just in case there is the chance that the Market field may include values using the apostrophe character.
 

Users who are viewing this thread

Back
Top Bottom