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!
15 replies
-
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
-
Thanks, Nick. I'll try it out.
-
Nick, does it also work if the table is sorted by something else (like country names on a dropdown or alphabetically by text)?
-
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")
endPrevious 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 -
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.
Nick
-
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'
-
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
-
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
- 1 mth agoLast active
- 15Replies
- 3682Views
-
3
Following