You probably don't need a script for that. Go into layout mode and select the field. Open the inspector, open the data tab then the behavior section. Then check retrun and enter for go to next object. Under the layout menu select tab order and set up the the order in which you want to move to objects. Make sure you clear out itme you don't want the user to go to.
I actually want the capability to tab through other fields also in the portal, but if I just want to enter data in the first field only, I want to use the "return" key to take me to the last portal row.
In that case you can use an OnObjectkeystroke combined with get(triggerkeystroke). Develop a script that interprets the characters using the Code function.
So you script should look something like this:
Set Variable [$c; code(getTriggerKeystroke]
if [$c = 10 or $c = 13 // 10 = Enter 13 = Return
perform Script [ move to last portal row] // Your script probaby should committ the record and the go to the Portal Object and then last portal row.
set field [ table::field; table::field & $c]
I haven't tested this on a field value but have used something very similar with OnLayoutKeystroke using a global field and scripted seaches.
If you are still having trouble post your script or a small version of your DB so others can take a look.
Thanks for your solution. I've created a test file and for some reason, when I hit the return key, the script does not end. after 5 seconds, you can see the cancel icon appear where your mouse curser is, indicating that the script is still running. I've attached the file to the original post. Any help is greatly appreciated!
This will do it. Since you do not want the return added to the field, you need to tell the event to not execute the keystroke, that's where the Exit Script (false) comes in
Note however that this will always to to the very last row in your portal, not sure that is whay you intended to do. You can avoid tthe commit and just do Go To Next Portal Row
That is exactly what I want it to do! Thanks so much!