Use value from previous field

H

Hlewis

I'm wondering if a query can use the value from the previous record if the
field meets a certain critera. I was thinking this would be possible in an
If statement but I don't know what the command would be. For example:
IIF(right([acct no],5)="*OPP1",use previous record,"114")

In this example, if the last 5 digit in the account number equls "*OPP1",
then use the vaule from previous record. If not use "114". Is this at all
possible?
 
J

John Vinson

I'm wondering if a query can use the value from the previous record if the
field meets a certain critera. I was thinking this would be possible in an
If statement but I don't know what the command would be. For example:
IIF(right([acct no],5)="*OPP1",use previous record,"114")

In this example, if the last 5 digit in the account number equls "*OPP1",
then use the vaule from previous record. If not use "114". Is this at all
possible?

It sounds like you've got some design problems! A field in a table
should depend on that table's Primary Key, and not on other fields in
the table nor on other records in the table.

Bear in mind that "the previous record" is a meaningless expression in
a Table; tables HAVE no definable order.

What's the context? Is this in the course of data entry? If so, I
presume you're using a Form; you could use the AfterUpdate event of
the [acct no] field and use DLookUp to find the value from the
previous record, or there may be other approaches.

John W. Vinson[MVP]
 
Top