0

button to number records incrementally

I am trying to write script for a button in order to number a series of records. Here is the situation:

It is to give a candidate number for an audition.

I have a "Candidates" table with their details which I can filter to "chosen" and which are all in a year table of application. I have put a number field which is now empty so they can have a number once chosen.

In my "Year" table I show a view of the candidates, which I can of course filter into chosen and sort by age.

I would like to have a button that will start the first candidate at 1 and number through to the last "chosen" one in increments of 1. Not having much luck. I was thinking of using this kind of logic , but I'm not very good with the for/do loops:

let Y := Year;
(select Candidates where Year=Y and Filter="Chosen" order by "DOBirth").number +1

can anyone help? Do I put the button on the "year" table or its child table candidates?

2 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 8 mths ago
    • Reported - view

    you can try something like:

    let Y := Year;
    let c := 1;
    for i in select Candidates where Year=Y and text(Filter)="Chosen" order by DOBirth do
    i.number := c;
    c := c+1
    end

    You put the button in the table where the field Year is.

      • Sean_Wood
      • 8 mths ago
      • Reported - view

      Perfect! Thank you so much Steven, it works like a charm. I even got the order to be in reverse of the Date of Birth (so you get people sorted by age) by placing a "-" before the DOB field.

      I used your script to also make an erase button and reset all the candidates' number to null.

      Great.

Content aside

  • 8 mths agoLast active
  • 2Replies
  • 33Views
  • 2 Following