Another newbie question: Collecting field from another table

J

Joost Nicasie

Hi all,

Another one that's probably simple but I can't figure it out.

I've got a query in which I generate a code, based on some fields from
a table. There's another table with the same codes and per code a
matching description. How do I get the description in the query? I
figured I should use Dlookup but I can't seem to write the right
syntax.

Anyone?

Cheers,
Joost
--
"I believe the light that shines on you
Will shine on you forever
And though I can't guarantee
There's nothing scary hiding under your bed
I’m gonna stand guard
Like a postcard of a Golden Retriever"
--Paul Simon
 
J

John Vinson

Hi all,

Another one that's probably simple but I can't figure it out.

I've got a query in which I generate a code, based on some fields from
a table. There's another table with the same codes and per code a
matching description. How do I get the description in the query? I
figured I should use Dlookup but I can't seem to write the right
syntax.

Anyone?

Cheers,
Joost

DLookUp is the right choice. DLookUp has three arguments, all of which
must be text strings:

1. The name of the field that you want to look up
2. The name of the Table or Query in which you want to look it up
3. A text string which evaluates to a legal SQL WHERE clause
identifying which record you want to look up

Since you don't describe your table or field names, I can only
suggest:

DLookUp("Description", "[tblCodes]", "
Code:
 = '" & [CalcCode] & "'")

This assumes that you have a text field named CalcCode in your query,
and want to look up the corresponding Description in tblCodes. If
[Code] is a text field you need the ' delimiters; if it's numeric,
leave them out:

DLookUp("Description", "[tblCodes]", "[Code] = " & [CalcCode])


John W. Vinson[MVP]
(no longer chatting for now)
 

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