previous record

fabiobarreto10

Registered User.
Local time
Today, 19:53
Joined
Dec 28, 2011
Messages
45
In VBA, as I refer to a field value from the previous record in a subform.
 
Are you asking a question?
 
It is not clear what you are trying to ask. Can you restate the question?
 
okay.


I have a subform with four fields: step, the scheduled date, place and date rescheduled date.

By changing the field step, I need to identify the value of the field held the previous record date.

Thank you.
 
okay.


I have a subform with four fields: step, the scheduled date, place and date rescheduled date.

By changing the field step, I need to identify the value of the field held the previous record date.

Thank you.
 
I tried DLookup, but did not work:

DataAnterior = DLookup ("[DataRealizada]", "TblPassosStatus", "[CodPassosStatus] = Forms! [FFiltros]! [CodPassosStatus] -1")

Where did I go wrong?
 
Try this instead:
Code:
DataAnterior = DLookup ("[DataRealizada]", "TblPassosStatus", "[CodPassosStatus] = " & DateAdd("d", -1, Forms![FFiltros]![CodPassosStatus])
 
 
'If it is a date then you probably will need the octothorpes
 
DataAnterior = DLookup ("[DataRealizada]", "TblPassosStatus", "[CodPassosStatus] = [B][COLOR=red]#[/COLOR][/B]" & DateAdd("d", -1, Forms![FFiltros]![CodPassosStatus] [B][COLOR=red]& "#"[/COLOR][/B])

You don't include the form reference inside the quotes. You concatenate it in. But I prefer using the DateAdd function to get my date rather than just subtracting which is why I used that. Hopefully this will work for you.
 
Last edited:
It really is a date. I got it. I just added the name of the subform:

DataAnterior = DLookup("[DataRealizada]", "TblPassosStatus",
"[CodPassosStatus]=Forms![fFiltros]![subTblPassosStatus]![CodPassosStatus]-1")

I'll also try with the code you sent me. Thank you for help.
 

Users who are viewing this thread

Back
Top Bottom