Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to check data in the previous record

Status
Not open for further replies.

pdtit

Technical User
Nov 4, 2001
206
BE
Hey,

I want to check an amount (total of fields on my form) against the amount in the same field from the previous record.

Situation :
The cashier has to count the money in drawer every morning and evening. Since it is not always the same person, I want to have some control on the amounts entered.

Can I have my "totals-field" from record 2 (today) checked against totals-field of record 1 (yesterday evening), and if there is a difference, I'd like to get an explanation in an inputbox, which is stored for clarification.

Regards,

Peter
 
You can use DLookup referencing the KeyID field-1 or the PrevRecVal function
HTH
 
A form can only access one record at a time. To get data from a record other than the one being displayed, you'll need to use VBA code. The DLookup() function will probably be fine for getting the previous day's total, provided you have some field in the record that you can use to identify which record you want.

Adding a text box for an explanation shouldn't be any problem, except that it's not clear where you want to store whatever explanation is entered. Unless you're storing it in the current (today's) record, you'll have to use VBA code again to save it somewhere. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top