1

Updating Multiple Records with use of a button

I have a database that keeps track of lessons plans for homeschool.  I have tables for each of my subjects.  The fields include the date of the assignment, the assignment text and so on.    I know that I can select multiple record and then use the 'Update Multiple Records' feature to change the date for all of the selected records.  

What I am wondering - is there way to use a button to move the dates by 1 day ... but not for the whole table - I want it to do it from the date of the record where I click the button and all dates that are after that date.  

 

Here is a screenshot of my table

 

I want to be able to select a record (as seen in screenshot Nov 4, 2022 is selected) and I want to be able to press the 'Move Records By 1 day' button and it moves all records on Nov 4, 2022 and AFTER - but anything before November 4, 2022 would not be changed.

Is this possible?

I have this code in the button to change ALL records by one day... 

for i in select Bible do
    i.('Lesson Date' := date(year('Lesson Date'), month('Lesson Date'), day('Lesson Date') + 1))
end;
alert("Dates have been changed")

Is there any way that I can grab the selected record's date and use that as an if condition - if the lesson date is >= to the current record lesson date then make the change, if not, do nothing.

Any help is greatly appreciated.

2 replies

null
    • Fred
    • 2 yrs ago
    • Reported - view

    Like most things in Ninox there usually is a way. You can try this in a new button:

    let t := this;
    for i in select Bible['Lesson Date' >= t.'Lesson Date'] do
    ...
    

    Line 1 creates a variable t and links the current record to it to be used later.

    Line 2 modifies your previous for loop to add the brackets to filter your results from the Bible table. Here we have told Ninox to find records where the Lesson Date is greater than or equal to the Lesson Date of the current record (t).

      • kwatson8745
      • 2 yrs ago
      • Reported - view

      Fred Thanks for the input. That is what I needed! That worked!  

      I am enjoying learning more and more of what this program can do!

Content aside

  • 1 Likes
  • 2 yrs agoLast active
  • 2Replies
  • 321Views
  • 2 Following