DLookup in a Query

G

Guest

I want to use a DLookup in a calculation in a query, but I can't figure out
how to write it. The "expr" is ITEM_DESCRIPTION and the "domain" is
tblITEM_MASTER and the "criteria" is ITEM_NO which is a field from the same
query I want to write my expression in. The underlying table for the query
is tblMEAL_SUB.

I have a hard time with dLookup because it seems to me there are a hundred
ways to write it, depending on conditions.

Any help would be appreciated.
 
F

fredg

I want to use a DLookup in a calculation in a query, but I can't figure out
how to write it. The "expr" is ITEM_DESCRIPTION and the "domain" is
tblITEM_MASTER and the "criteria" is ITEM_NO which is a field from the same
query I want to write my expression in. The underlying table for the query
is tblMEAL_SUB.

I have a hard time with dLookup because it seems to me there are a hundred
ways to write it, depending on conditions.

Any help would be appreciated.

If [Item_No] is a Number datatype:
DLookUp("[Item_Description]","tblItem_Master","[Item_No] = " &
[Item_No])


If, however, [Item_No] is a Text datatype field, then:
DLookUp("[Item_Description]","tblItem_Master","[Item_No] = '" &
[Item_No] & "'")
 
G

Guest

That's exactly what I needed. I didn't account for a text field. Thank you.
--
Don Rountree


fredg said:
I want to use a DLookup in a calculation in a query, but I can't figure out
how to write it. The "expr" is ITEM_DESCRIPTION and the "domain" is
tblITEM_MASTER and the "criteria" is ITEM_NO which is a field from the same
query I want to write my expression in. The underlying table for the query
is tblMEAL_SUB.

I have a hard time with dLookup because it seems to me there are a hundred
ways to write it, depending on conditions.

Any help would be appreciated.

If [Item_No] is a Number datatype:
DLookUp("[Item_Description]","tblItem_Master","[Item_No] = " &
[Item_No])


If, however, [Item_No] is a Text datatype field, then:
DLookUp("[Item_Description]","tblItem_Master","[Item_No] = '" &
[Item_No] & "'")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DLookUp 4
DLookUp in a Query 2
Dlookup in Query 2
Dlookup in query 1
Dlookup 5
Dlookup Expression Error 2
Dlookup in query - any pointers? 1
DLookUp 2

Top