Dlookup Multiple Criteria

AndrewKent

Well-known Member
Joined
Jul 26, 2006
Messages
889
Hi there,

I have a table in Access that I am trying to lookup if two criteria are met.

The table I want to look up is "tblDefinitions_MonthEnd"

The field I want to return from this table is "MonthEnd_LastDate"

If "MonthEnd_Week" in the table matches "CL_Week" in my query

AND

If "MonthEnd_Year" in the table matches "CL_Year" in my query

Can anyone help structure this?

Andy
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
=dlookup("[MonthEnd_LastDate]","[tblDefinitions_MonthEnd]","[tblDefinitions_MonthEnd]![MonthEnd_Week]='" & [CL_Week] & "' AND [tblDefinitions_MonthEnd]![MonthEnd_Year] =" & [CL_Year])

should work assuming that [CL_Week] is text and [CL_Year] is a number
 
Last edited:
Upvote 0
Thanks, okay so I managed to complete the expression I wanted:

Tenure Banding: DLookUp("Tenure_Banding","tblDefinitions_Tenure","Tenure_MonthsService=" & DateDiff("m",[CL_StartDate],DLookUp("MonthEnd_LastDate","tblDefinitions_MonthEnd","MonthEnd_Week = " & [CL_Week] & " and MonthEnd_Year = '" & [CL_Year] & "'")) & ""

Which works, HOWEVER when access this again, it tells me I'm missing a ] or |

Does anything look missing here?

Andy
 
Upvote 0
Tenure Banding: DLookUp("[Tenure_Banding]","[tblDefinitions_Tenure]"," [tblDefinitions_Tenure]![Tenure_MonthsService]=" & DateDiff("m",[CL_StartDate],DLookUp("[MonthEnd_LastDate]","[tblDefinitions_MonthEnd]"," [tblDefinitions_MonthEnd]![MonthEnd_Week]=’" & [CL_Week] & "’ and [tblDefinitions_MonthEnd]![MonthEnd_Year]= " & [CL_Year] )))

Should work, its hard telling without knowing the data formats for each...let me know if it fails and how..
 
Upvote 0
Ahhh figured it out, there was nothing wrong with my expression, I built it BEFORE I put on grouping, then tried to access it WITH group on. then it caused problems. I'll just not access it in builder mode with grouping on.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

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