Referencing a table while using Dlookup on a form

N

nxqviet

Hi there,

My question is about writing a DlookUp statement, where the Criteria
can be found on a separate table.
For example,

Dlookup ("[LastName]", "tblNameList","[FirstName] = ' " &
[tblGuest]![FirstName] & " ' ")

The TblGuest contain only 1 row of data, thus, no addtional criteria
will be needed. I know that this code is wrong, but realy have a hard
time trying to fix it. I don't know how to accurately reference the
tblGuest table and the field [FirstName] in that table.

Please help me to complete this code.

Thanks for your help

V-
 
B

BruceS

V-

Try this:

Dlookup ("[LastName]", "tblNameList","[FirstName] = ' " &
(DLookup("[FirstName]","tblGuest")) & " ' ")

Bruce
 
N

nxqviet

Thanks Rick, it worked excellently.

V



Rick said:
Hi there,

My question is about writing a DlookUp statement, where the Criteria
can be found on a separate table.
For example,

Dlookup ("[LastName]", "tblNameList","[FirstName] = ' " &
[tblGuest]![FirstName] & " ' ")

The TblGuest contain only 1 row of data, thus, no addtional criteria
will be needed. I know that this code is wrong, but realy have a hard
time trying to fix it. I don't know how to accurately reference the
tblGuest table and the field [FirstName] in that table.

Please help me to complete this code.

Thanks for your help

V-

Even though it has only one row you need another DLookup() to get that
value...

DLookup ("[LastName]", "tblNameList","[FirstName] = '" &
DLookup("[FirstName]", "[tblGuest]") & "'")
 
N

nxqviet

Thanks for the help Bruce, I tried a similar code and it worked.

You are very helpful

V

V-

Try this:

Dlookup ("[LastName]", "tblNameList","[FirstName] = ' " &
(DLookup("[FirstName]","tblGuest")) & " ' ")

Bruce


Hi there,

My question is about writing a DlookUp statement, where the Criteria
can be found on a separate table.
For example,

Dlookup ("[LastName]", "tblNameList","[FirstName] = ' " &
[tblGuest]![FirstName] & " ' ")

The TblGuest contain only 1 row of data, thus, no addtional criteria
will be needed. I know that this code is wrong, but realy have a hard
time trying to fix it. I don't know how to accurately reference the
tblGuest table and the field [FirstName] in that table.

Please help me to complete this code.

Thanks for your help

V-
 

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

Top