using dlookup in a query (1 Viewer)

martinr

Registered User.
Local time
Today, 22:25
Joined
Nov 16, 2011
Messages
74
i have a question re: using dlookup in a query.

i need to include a 'looked up' cost value from a table in a query so this value can be used to calculate other fields (oncosts etc) within the Query.

If I use Dlookup in the query can I reference the matching record Code within the query itself?
Eg; the matching values required are in Table2 and the Query is called ‘queryFreight’, so i'm trying this (but not working);

Dlookup ([ProductFreightCost],[Table2], [Table2].[ProductID]=[queryFreight].[productcode])

is this the correct syntax?
Also, what does the function return if the lookup value isn't found - no matching productID?
 

Alansidman

AWF VIP
Local time
Today, 07:25
Joined
Jul 31, 2008
Messages
1,493
Look at this link for the proper syntax and use of quotation marks, ie. "
 

plog

Banishment Pending
Local time
Today, 07:25
Joined
May 11, 2011
Messages
11,638
Why a Dlookup? Queries are a way to join tables and pull related data from them....So, why not just bring Table2 into the query and link it in the manner it needs to be? Then you can just reference [ProductFreightCost] directly.
 

MSAccessRookie

AWF VIP
Local time
Today, 08:25
Joined
May 2, 2008
Messages
3,428
Why a Dlookup? Queries are a way to join tables and pull related data from them....So, why not just bring Table2 into the query and link it in the manner it needs to be? Then you can just reference [ProductFreightCost] directly.

I totally agree with plog here, and to expand on what he is saying, It has been my experience that not only does a DLookup not return results as fast as a Joined Table Link, but as the amount of Data being processed gets larger, the length of time for the DLookup gets longer as well.

-- Rookie
 

Users who are viewing this thread

Top Bottom