Dlookup multiple criteria

Apple08

Active Member
Joined
Nov 1, 2014
Messages
450
Hi everyone

Please could someone help me to check the below Dlookup formula:

PreviousRAGid: DLookUp("[CurrentRAGid]","strategicProjectFinance","[strategicProjectFinanceID]=" & [strategicProjectFinanceID] & " And [monthID]=#" & DateSerial(Year([monthID]),Month([monthID]),0) & "#")

I want the previous month RAGid from the above formula, but it doesn't work. It turns out with nothing in the PreviousRAGid field. Have I done something wrong?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
What kind of values do you have for MonthID? Is that an actual date value? Or a numeric ID? Or actually a text value? Same might be asked of FinanceID.
 
Upvote 0
Thanks for trying to help.

monthID is actual date, it's always the end of a month such as 31/07/2016
financeID is auto number which is unique
strategicProjectFinance is the query name
CurrentRAGid is in number format
 
Upvote 0
Test your dlookup using a sql statement.
Code:
select * from strategicProjectFinance where strategicProjectFinanceID = 1 and monthID = #31/07/2016#
 
Upvote 0
I have changed the ID to 9 instead of 1 as 1 was in June. However there is no value for the Previous RAG though.
 
Upvote 0
On the face of it, it seems that the query is correct and return no value because no value exists matching your criteria. What are you expecting it to return? What data is in the tables? What does the query you are querying do (strategicProjectFinance ) - does it also have the record you are looking for?
 
Upvote 0
I have currentRAGid in the strategicProjectFinance query, with RAG status from 1 to 3. All I want the return is to look for last month's currentRAGID and auto input as this month's previousRAGid. So if the June's currentRAGID is 2, then in July, the previousRAGid will be showing as 2 automatically.
 
Upvote 0
The currentRAGid in June should be 1, 2 and 4 and I expect a return of 1,2 and 4 in the previousRAGid in July, however it returns all in 1 after I modify as below:

PreviousRAGid: DLookUp("[CurrentRAGid]","strategicProjectFinance","[strategicProjectFinanceID]=" & [strategicProjectFinanceID] & "# " And "[monthID]=#" & DateSerial(Year([monthID]),Month([monthID]),0) & "#")
 
Upvote 0
expect a return of 1,2 and 4 in the previousRAGid in July
A DLookup function cannot return multiple values. Just one. You may be seeing the first value here.
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

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