current record and previous record

G

Guest

I have a form where I need to know what is in the the same field in the last
or previous record so I can do math in the form on it.

I have a field named NrOfCarts where each entry is assigned a autonumber id.
I was using the ID -1 to find the record before the current record but if I
delete a record I can no longer determine what the autonumber is of the field
before the current record.

If the table stores this data in autonumber order even though there are
missing numbers How can I get the information from the previous record.


ie table
autonumber ID NoOfCarts
1 10
2 5
3 15
4 30
7 current record and need to know what is in
last id 4 or 30

Thanks in advance for any assistance you can provide......greatly appreciated.
 
D

Douglas J Steele

You could have a subquery that finds the largest ID that's less than the
current ID, or you could use DMax (with a reference to the current ID).
 
A

Al Camp

Hansford,
In addition to Douglas' solution...
Using Ctrl ' (Ctrl apostrophe) in your NoOfCarts field will copy the
NoOfCarts value from the previous record. Always make sure that your
records are sorted properly... in the order they were entered.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top