0

How to create a button that clicks through forms

I'd like to put a button on the first tab of my form that, when clicked, opens the next record down on the table. The same as using the down-arrow on the keyboard. What script would i need for the button? Thanks!

8 replies

null
    • Nick
    • 5 yrs ago
    • Reported - view

    Next Record:

    let thisNUM := number(Id);
    let myNUM := min((select yourTable)[number(Id) > thisNUM].number(Id));
    openRecord(record(yourTable,myNUM))

     

    Previous Record:

    let thisNUM := number(Id);
    let myNUM := max((select yourTable)[number(Id) < thisNUM].number(Id));
    openRecord(record(yourTable,myNUM))

     

    These buttons works right when table sorted by Id.

     

    Nick

    • David
    • 5 yrs ago
    • Reported - view

    Thanks, Nick. I'll try it out. 

    • David
    • 5 yrs ago
    • Reported - view

    Nick, does it also work if the table is sorted by something else (like country names on a dropdown or alphabetically by text)?

    • Sean
    • 5 yrs ago
    • Reported - view

    I don't know if this is still relevant, but this is a solution I came up with for sorted views.

     

    Next Record:

    let txtThisName := NameField;
    let aryNames := (select Table1)[NameField > txtThisName].NameField;
    let arySortedNames := sort(aryNames);
    let numNextId := min((select Table1)[NameField = item(arySortedNames, 0)].number(Id));
    if cnt(arySortedNames) != 0 then
    openRecord(record(Table1,numNextId))
    else
    alert("End of Table")
    end

     

    Previous Record:

    let txtThisName := NameField;
    let aryNames := (select Table1)[NameField < txtThisName].NameField;
    let arySortedNames := rsort(aryNames);
    let numNextId := min((select Table1)[NameField = item(arySortedNames, 0)].number(Id));
    if cnt(arySortedNames) != 0 then
    openRecord(record(Table1,numNextId))
    else
    alert("Beginning of Table")
    end

    • Nick
    • 5 yrs ago
    • Reported - view

    All these are workarounds that doesn't work right.

    Lets's hope Ninox Team add the functions

    goToRecord (Next)

    goToRecord (Last) etc.

    The code is already hard coded to the app.

    Screen Shot 2018-10-02 at 22.23.21

    Nick

    • Sean
    • 5 yrs ago
    • Reported - view

    Hey Nick, I'm confused. You seem a little hostile and you responded with a workaround yourself. I simply thought it was an interesting exercise and I am aware that those navigation controls exist. The OP has started many threads that are somewhat misguided and could be cleared up by taking some time to learn how develop a database properly.

     

    Oh yeah, the code works. Just sayin'

    • Nick
    • 5 yrs ago
    • Reported - view

    No, no hostile at all! Don't get me wrong.

    I love the app, and (as you said about my responce) I'm trying to help other users.

    I just say that I am not completely satisfied (my workaround included). And as I try to find solutions that could be simple.

    And of course I love exercises too!

     

    Nick

    • Sean
    • 5 yrs ago
    • Reported - view

    Cool. I enjoy working with the app also and I'm looking forward to the next release which will hopefully include some of the enhancements we have been asking for.

    I know my workaround is ugly, but I had fun making it happen anyway.  ;)

     

    Sean

Content aside

  • 5 yrs agoLast active
  • 8Replies
  • 3584Views
  • 1 Following