Dlookup ?

J

Jeanke

Hello all,

have 1 table that has field currency which contains the
currency type like USD,EUR,GBP,...

Have 2nd table that has the values for the currencies over
the years
fields : currency, year, value

In a query I want to create a field that looks up the
value of the currency in table 1 for a specific year.

tried this :
Dlookup("[currency]","table2",[table2]![currency]"=2005)

but this doesn't give me nor an error, nor a value.

What am I doing wrong
 
D

Duane Hookom

Try: Dlookup("[currency]","table2", "[currency]=2005")
I would bet the returned value should be 2005 (if the value exists in the
table).
 
V

Van T. Dinh

From your description, it should be something like:

DLookUp("[Value]", "Table2", "[Currency] = 'USD'" And
"[Year] = 2005" )

Both "Currency" and "Year" are reserved words in some areas of Access / VBA.
I would recommend changing your Field names so that they are not the same
with reserved words.
 
G

Gary Walter

Actually Jeanke, I believe you accomplished
a "trifecta" since "Value" is a reserved word also. :cool:

Van T. Dinh said:
From your description, it should be something like:

DLookUp("[Value]", "Table2", "[Currency] = 'USD'" And
"[Year] = 2005" )

Both "Currency" and "Year" are reserved words in some areas of Access / VBA.
I would recommend changing your Field names so that they are not the same
with reserved words.

--
HTH
Van T. Dinh
MVP (Access)




Jeanke said:
Hello all,

have 1 table that has field currency which contains the
currency type like USD,EUR,GBP,...

Have 2nd table that has the values for the currencies over
the years
fields : currency, year, value

In a query I want to create a field that looks up the
value of the currency in table 1 for a specific year.

tried this :
Dlookup("[currency]","table2",[table2]![currency]"=2005)

but this doesn't give me nor an error, nor a value.

What am I doing wrong
 

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