0

Previous record

I am new to Ninox. I have a simple database to keep track of mileage on my car (to check on Allstate numbers). Thus far, I have only two data fields: date and odometer mileage. I would like to access the previous record, copy both data fields into the current record, into new fields called previous date and previous mileage. 

 

I would appreciate any suggestion.

4 replies

null
    • Fred
    • 6 mths ago
    • Reported - view

    Will you ever enter two records with the same date?

    Might you ever enter in a record that is not sequential? You forgot a day and now want to go back and add it after you have added subsequent days?

    I'm guessing you are using the Mac app.

    • Accountant
    • George_J_Sova
    • 6 mths ago
    • Reported - view

    New record is created every 2nd or 3rd week; there are no records with the same date. All records are in a  strict sequence. I never go back and insert a record into the past history. I do use the Mac application.

    I do appreciate your prompt response.

    George

      • szormpas
      • 6 mths ago
      • Reported - view

         Hi, If I understand your intention correctly, a solution would be to place the following code in the 'Trigger on new record' field:

      let x := number(this);
      let y := record(YOUR TABLE,x - 1);
      'previous date' := y.date;
      'previous mileage' := y.'odometer mileage';
      
      • Fred
      • 6 mths ago
      • Reported - view

      I like the use of the record() command. I probably would've started with a select(), but this is much faster.

      May I recommend that with any new code, you first put it in a button to make sure it does what you want before you let it lose in a Trigger. This is especially true with code with loops.

Content aside

  • Status Answered
  • 6 mths agoLast active
  • 4Replies
  • 75Views
  • 3 Following