View Full Version : Dlookup find previous record does not work


ppataki
02-15-2010, 04:33 AM
Dear All,

I have an aggregate query that displays certain fields of a table
I would like to display the values of the previous record of one of the fields

I have used this formula:

Expr1: DLookUp("[creditlimitcp]";"[tbl_annualdata]";"[yeardata] = " & [yeardata]-1)

but it only works for one "group" and copies that data for all the others
I attached a screenshot to better understand the problem (circled the part that works)
Could you please advise?
Many thanks in advance ;)

RuralGuy
02-15-2010, 06:31 AM
It looks to me like your criteria is not adequate to properly select the record you want.

ppataki
02-15-2010, 07:37 AM
What other criterion shall I use?
Thank you in advance!

RuralGuy
02-15-2010, 07:46 AM
Try:
Expr1: DLookUp("[creditlimitcp]";"[tbl_annualdata]";"[Custname] = " & [CustName] & " AND [yeardata] = " & [yeardata]-1)

ppataki
02-15-2010, 11:32 PM
I get #Error values in the field...any suggestions please?
Thank you

RuralGuy
02-16-2010, 04:15 AM
I forgot CustName was a string:
Expr1: DLookUp("[creditlimitcp]";"[tbl_annualdata]";"[Custname] = '" & [CustName] & "' AND [yeardata] = " & [yeardata]-1)