show value from previous record

amalfi93

New member
Local time
Today, 22:12
Joined
Sep 4, 2003
Messages
5
I would like to be able to populate a text box on a form with a value (field = MILES) from the previous record. I would then like to use a calculated control to subtract the previous MILES value from the MILES value of the current record.

Any help would be appreciated.
 
How about a little more explanation. I'm not clear on the calculation part. You should be able to use an update query to get the previous miles in the current record.
 
more info...

Jon- Thanks for the response.

I have created a form for entering automobile fuel purchases and recording the odometer reading at the time of fueling. I would like to display the fuel economy (miles per gallon) for each vehicle in order to keep track of vehicle performance. In order to do this, the difference in current odometer reading and the previous odometer reading must be divided by the number of gallons of fuel pumped into the vehicle.

I understand how to do the math on the form but not how to access the odometer value from the previous record.
 
still trying...

I used the code from dcx693 and unfortunately it sets the default value of the current record (text box in the data entry form) = to the value of the previous record (same field).

In a table, I have two fields (call them Field1 and Field2). I have created a form with text boxes linked to each of those two fields.

When the user goes to create a new record, the textbox for Field2 of the current record (new record) should automatically be populated with the value of Field 1 from the previous record.

You mentioned using an update query...?
 
OK. I think with that detail you don't want an update query. Say you have a form to view details about a vehicle. You could open another form to add mileage information for that vehicle. You enter the gallons purchased and odometer reading. I think if you can use the DMax function (look for DMax in help) to find the highest odometer reading for that vehicle to use in your calculation. You have to be sure to perform the calculation before the record is updated, so it is looking at previous records. I think a search in help and here for DMax will get you far.
 
Jon - I think the DMAX function will solve my problem. Thanks again for your help.


Cheers
 

Users who are viewing this thread

Back
Top Bottom