"Cydney"wrote:
I am using a query to look up an exchange rate (or conversion rate) from a
table of weekly date ranges. I need to find the associated currency
exchange
rate for that week where the expense occurred ("[PERIOD_END_DATE]").
My query formula is below. I can't figure out why it doesn't work. Can
you
help?
ConvRate:
DLookUp("[CONVERSION_RATE]","CurrencyConversion","MyData.[PERIOD_END_DATE]
Between [effective_start_date] And [effective_end_date]")
--
it sounds like you have a table "CurrencyConversion"
with 3 fields
effective_start_date effective_end_date CONVERSION_RATE
6/4/2006 6/10/2006 1.6
6/11/2006 6/17/2006 1.8
6/18/2006 6/24/2006 1.5
and in a query based on table "MyData"
you want to determine the rate based on
MyData.PERIOD_END_DATE
If MyData is the only table in your query,
then the simplest solution would be just to
add the table "CurrencyConversion" to the
query without any joins (what they call a
Cartesian Join),
right-mouse click on this table in query designer,
choose "Properties"
set "Alias" to CC
double-click on CONVERSION_RATE
to add it as a new column in the grid
then, in "Criteria" row under PERIOD_END_DATE
column, type in (all one line)
= CC.effective_start_date AND < CC.effective_end_date + 1
if you have more than one table in the original query,
then your domain function will need to separate out
the "domain stuff" from the "query stuff" in the where
portion of the domain function, i.e.,
the 2 effective date fields are part of the CurrencyConversion
domain, but PERIOD_END_DATE comes from "outside of
that domain"
ConvRate:
DLookUp("[CONVERSION_RATE]","CurrencyConversion",
"[effective_start_date] <= # " & MyData.[PERIOD_END_DATE]
& "# AND [effective_end_date] + 1 > #"
& MyData.[PERIOD_END_DATE]
& "#")