Using DLOOKUP with >= operator?

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
Hi, I have a DLOOKUP question. How do you set up DLOOKUP to work like VLOOKUP in Excel, or don't you? :confused:
Example:
Table1 -- Levy
EffectiveDate LevyRate
1-Jan-02 2%
1-Jan-03 4%
1-Jan-04 3.5%

Table2
TransDate Other Fields
Range of transactions, varying dates.

I'd like to build an expression to place the correct effective dates against each transaction date. Have tried

=DLookUp("[LevyRate]","Levy","[Effective Date] >=" & [Transdate])
=DLookUp("[LevyRate]","Levy","[Effective Date] >=" & "[Transdate]")
=DLookUp("[LevyRate]","Levy","[Effective Date] >= [Transdate]")

I think the first option is closest, but still no dice -- I get 0 values for all records. Can the > or >= operators be used with DLOOKUP, or do I need another approach?

Thanks in advance
Denis
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Are the effective date and transaction date linked by year?
 
Upvote 0
Hi Norie,
No, there is no link between the tables. I often use this as a way to populate a query with a single value -- sort of a global variable.

I'm currently trying a different approach, using the OnCurrent and AfterUpdate events of the form to (a) load the values into unbound controls and (b) populate the LevyPercent field if the Transaction Date is >= EffectiveDate. So far, it seems to be working but the users of this db have an uncanny knack of stuffing things up, so I was hoping for a calculation-based approach.

Denis
 
Upvote 0
I didn't mean a link between tables.

I meant something like if the year of the effective date is the same as that of the transaction date then use that levy rate.

I was thinking of using the Year function in a query.

e.g.

SELECT [Trans Table].TransDate, [Levy Table].Levy
FROM [Trans Table] INNER JOIN [Levy Table] ON Year([Trans Table].TransDate) = Year([Levy Table].EffectiveDate);
 
Upvote 0
Ahh... OK, I misunderstood where you were coming from.

Unfortunately I need to match the whole date because the levy is likely to change on a monthly basis.

Denis
 
Upvote 0
How about

SELECT [Trans Table].TransDate, [Levy Table].Levy
FROM [Trans Table] INNER JOIN [Levy Table] ON ([Trans Table].TransDate) < ([Levy Table].EffectiveDate);
 
Upvote 0

Forum statistics

Threads
1,221,714
Messages
6,161,467
Members
451,708
Latest member
PedroMoss2268

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top