Dmax of Date

syedadnan

Access Lover
Local time
Today, 08:16
Joined
Mar 27, 2013
Messages
315
Regards,

I am stuck here with a problem that i need a dlookup value of field "A_bal" with respect to bank id "BID" and max of date field "Tdate".

The query name is TNS

an image is attacched
 

Attachments

  • Dmax.png
    Dmax.png
    14.9 KB · Views: 238
make 2 queries.
Q1 is: select ID, MAX(date) from tabl (now you know the max date of each ID)

now get the balance...
Q2 uses Q1 and tabl , then the ID in Q1 to pull the balance, join the 2 on ID.
 
DLookup

Something along this line:(untested)
DesiredValue = DLookup("a_bal","yourtableOrQueryName","aBID=" & txtBID & " and TDate =#" &TDate & "#")

Need more context for the issue to do a test.
 
DLookup

Something along this line:(untested)
DesiredValue = DLookup("a_bal","yourtableOrQueryName","aBID=" & txtBID & " and TDate =#" &TDate & "#")

Need more context for the issue to do a test.

Not working.. as for what i need..
 
make 2 queries.
Q1 is: select ID, MAX(date) from tabl (now you know the max date of each ID)

now get the balance...
Q2 uses Q1 and tabl , then the ID in Q1 to pull the balance, join the 2 on ID.



Not working.. i think something with dlookup and dmax nest will work.. waiting for any other idea
 
SELECT DISTINCT T1.BID, CDATE(DMax("TDATE","yourTABLE","BID=" & T1.BID)) AS TDATE, CDbl(DLookUp("A_BAL","yourTABLE","BID=" & [T1].[BID] & " AND TDATE=#" & DMax("TDATE","yourTABLE","BID=" & [T1].[BID]) & "#")) AS A_BAL
FROM yourTABLE AS T1;
 
SELECT DISTINCT T1.BID, CDATE(DMax("TDATE","yourTABLE","BID=" & T1.BID)) AS TDATE, CDbl(DLookUp("A_BAL","yourTABLE","BID=" & [T1].[BID] & " AND TDATE=#" & DMax("TDATE","yourTABLE","BID=" & [T1].[BID]) & "#")) AS A_BAL
FROM yourTABLE AS T1;

WOW !! Thats great cent percent to the requirement... Thanks a billion have a nice day...
 

Users who are viewing this thread

Back
Top Bottom