AnsweredAssumed Answered

How to get data from prior record?

Question asked by acmeoutdoor on Jan 3, 2017
Latest reply on Jun 27, 2017 by gofmp15

Using FM 15, I made a simple fuel log to record gas purchases and calculate MPG. 

 

I want to write a script that will get the value from the previous record's ENDING ODOMETER field (as determined by a RECORD ID field) and insert it into the BEGINNING ODOMETER field of a new record.    For example, if the newly created record has a RECORD ID of 17 I want the script to retrieve the ENDING ODOMETER value from RECORD ID 16 and insert that value into the BEGINNING ODOMETER field in RECORD ID 17.   The script I wrote however returns the ENDING ODOMETER value from RECORD ID 1 (the oldest record) and inserts it into the BEGINNING ODOMETER field of the newly created record. 

 

The script I wrote is:

Enter find mode [Pause: off] Perform Find [Restore]    ACTION - Find Records    CRITERIA - Fuel Log::RECORD ID:[>0] 

Sort Records By Field [ Ascending ; Fuel Log::RECORD ID]

Enter Browse Mode [Pause: Off]

Go To Record/Request/Page [ with Dialog: Off ; Max ( Fuel Log::RECORD ID )] 

Go To Field [Select/Perform ; Fuel Log::Odometer End ] 

Copy [Select] 

Go To Record/Request/Page [ Last] 

Paste [Select ; Fuel Log::Odometer Start] 

Enter Browse Mode [ Pause Off ] 

 

What am I doing wrong?  Do I need a script or is there an easier method?

Outcomes