Dlookup in Query

D

Dave

Need help with the criteria portion of a Dlookup.
This dlookup is in the "Field" portion of a query.
The query is a single table query pulling from the orders table.
There are reasons I can't pull other tables into this query.
I am trying to pull in the customer name(not in the "Orders" table) for
each "order" in the Order List this Query is generating.

I just don't know how the syntex of the criteria is written.

FirstName:dlookup("CustomerFirst","tblCustomers","")

Thanks in advance,

D
 
J

John W. Vinson

Need help with the criteria portion of a Dlookup.
This dlookup is in the "Field" portion of a query.
The query is a single table query pulling from the orders table.
There are reasons I can't pull other tables into this query.
I am trying to pull in the customer name(not in the "Orders" table) for
each "order" in the Order List this Query is generating.

I just don't know how the syntex of the criteria is written.

FirstName:dlookup("CustomerFirst","tblCustomers","")

Thanks in advance,

D

You don't give any indication what fields exist in your orders table or in the
customer table which would provide a link, so I'll make a plausible guess that
you have a CustomerID field in each.

The third argument to any domain function is a String which evaluates to a
valid SQL WHERE clause without the WHERE. So if you have an order selected for
customer 3161, the third argument should be

"[CustomerID] = 3161"

YOu can build this string up from pieces by concatenating string literals (in
quotes) with values from the other fields in the query:

DLookUp("[CustomerFirst]", "[tblCustomers]", "[CustomerID] = " & [CustomerID])

The first customerID - in quotes - is a text literal referring to the field in
tblCustomers; the second is a variable referring to the CustomerID field's
value in the order table.

John W. Vinson [MVP]
 
D

Dave

Yep John - That was just want I needed.
Sorry about the lack of details.

Thank you.
D
John W. Vinson said:
Need help with the criteria portion of a Dlookup.
This dlookup is in the "Field" portion of a query.
The query is a single table query pulling from the orders table.
There are reasons I can't pull other tables into this query.
I am trying to pull in the customer name(not in the "Orders" table) for
each "order" in the Order List this Query is generating.

I just don't know how the syntex of the criteria is written.

FirstName:dlookup("CustomerFirst","tblCustomers","")

Thanks in advance,

D

You don't give any indication what fields exist in your orders table or in
the
customer table which would provide a link, so I'll make a plausible guess
that
you have a CustomerID field in each.

The third argument to any domain function is a String which evaluates to a
valid SQL WHERE clause without the WHERE. So if you have an order selected
for
customer 3161, the third argument should be

"[CustomerID] = 3161"

YOu can build this string up from pieces by concatenating string literals
(in
quotes) with values from the other fields in the query:

DLookUp("[CustomerFirst]", "[tblCustomers]", "[CustomerID] = " &
[CustomerID])

The first customerID - in quotes - is a text literal referring to the
field in
tblCustomers; the second is a variable referring to the CustomerID field's
value in the order table.

John W. Vinson [MVP]
 

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

Checking if data exists another table and, if yes, extracting a value 0
DLookUp 4
Dlookup won't work - help 3
Dlookup in query 1
DLookUp in a Query 2
DLookUp 2
Dlookup function 4
Dlookup 5

Top