1 2 Previous Next 19 Replies Latest reply on Sep 24, 2010 9:34 AM by cmspe

    moving the 'record pointer' using a script trigger

    cmspe

      Title

      moving the 'record pointer' using a script trigger

      Post

      I have a TO that filters out a group of records.  In the layout I have one field that I want to enter info into for each record.  In Access, I would just hit the return button and it would go to the next record.  After reading a post "moving the 'record pointer'", I tried using the "go to record/request/page[next]" script and placing it as a script tigger so that after exiting the field, it would go to the next record.  Every time I use it, it races all the way down to the last record, not stopping at the 'next record'.  I then added the "go to field[...]" script right after the "go to record..." script, but that didn't change things.  How can I get my layout to allow me to enter info into one field and have it go to the next record, same field?  I've tried it in form and list view, but they both do the same thing.

        • 1. Re: moving the 'record pointer' using a script trigger
          sunmoonstar.13

          Go to Layout Setup and attach the following script as a Script Trigger to OnLayoutKeystroke:


          If [ Code (Get (TriggerKeystroke)) = 10 or Code (Get (TriggerKystroke)) = 13 ] 
                Go to Record/Request/Page [Next]
          End If

          Then, whenever you press the Enter or Return key, it will progress to the next record.

          Alternatively, instead of doing any of the above, you could simply press Ctrl-down arrow to progress to the next record, or Ctrl-up arrow to go backwards through the records.

          (BTW, I tested out your script trigger on exiting a field and it replicated the same behaviour of skipping to the last record. I have no idea why it does that.)

          Nick

           

           

          • 2. Re: moving the 'record pointer' using a script trigger
            cmspe

            Thanks for the script, but the behavior is the same.  As soon as I press the Enter or Return key, it skips all the way down to the last record.  I know about the Ctrl-down arrow, but I don't want to have to use it for one purpose, the information I'm inputting into the field is numerical and therefore I use the number keypad.  Using the Ctrl-down arrow will slow down the input significantly.

            • 3. Re: moving the 'record pointer' using a script trigger
              philmodjunk

              The original script runs to the end of the found set because the script itself is tripping the same onObjecExit trigger that calls it in the first place. You can fix this with an Exit Script [Result: False ] step, but you'll still trigger this script any time you click outside the field.

              SunMoonStar_13's script makes more sense as it would not fire the script if you clicked outside the field. I'd add a few more details though:

               If [ Code (Get (TriggerKeystroke)) = 10 or Code (Get (TriggerKystroke)) = 13 or Code (Get (TriggerKeystroke)) = 9 ] 
                    Go To Field [//specify first field in tab order]
                    Go to Record/Request/Page [Next]
                    Exit Script [Result: False]
              End If

              Adding code 9 makes the script also respond to the tab key. The exit script step keeps it from inserting a carriage return in the next field it goes to.

              Also, make sure you disable the OnObjectExit trigger when you add the OnObjectKeystroke trigger for the above script.

              • 4. Re: moving the 'record pointer' using a script trigger
                sunmoonstar.13

                The script I suggested was intended to be attached to the layout as an OnLayoutKeystroke script trigger, not attached to the field as an OnObjectKeystroke trigger. As a layout trigger, the script that I suggested doesn't require any modification to work and doesn't require the cursor to be inside a field.

                Also, I dont think it's necessary to add the Tab key into the script, because the Tab key is better used for its native function of tabbing to different fields. Why tie up more keys in the script than is necessary? I reckon the Enter and Return keys are sufficient options in this situation.

                But yes, the OnObjectExit trigger on the field needs to be disabled, regardless.

                Nick

                 

                • 5. Re: moving the 'record pointer' using a script trigger
                  LaRetta_1

                  If you attach OnObjectExit trigger only to the last field in the list, it could be:

                  Go To Field [ first field in the list ]

                  Go To Record/Request/Page [ Next ]

                  BTW, if this is form view, be sure to attch a clear record indicator or display the primary key (with entry turned off) so Users will know it has jumped to the next record.  Otherwise they can be changing data in the wrong fields.

                  • 6. Re: moving the 'record pointer' using a script trigger
                    cmspe

                    Nick

                    I changed it to OnLayoutKeystroke and it works great.  I have one request, how do you turn off the beep that occurs each time I press the enter/return key?

                    • 7. Re: moving the 'record pointer' using a script trigger
                      sunmoonstar.13

                      There's a beep? There shouldn't be a beep.

                      Did you happen to add the "Beep" script step to the script? If so, get rid of it.

                      Did you add anything else to the script?

                       

                      Nick

                      • 8. Re: moving the 'record pointer' using a script trigger
                        cmspe

                        I haven't added any "Beep" script anywhere, neither have I added anything else.  It beeps (alert beep) on both my Mac and PC running filemaker.  This is my code:

                        If [ Code (Get (TriggerKeystroke)) = 10 or Code (Get  (TriggerKystroke)) = 13 ] 
                              Go to Record/Request/Page [Next]
                        End If

                        • 9. Re: moving the 'record pointer' using a script trigger
                          sunmoonstar.13

                          > I haven't added any "Beep" script anywhere, neither have I added anything else.  It beeps (alert beep) on both my Mac and PC running filemaker. 

                          Hmm...not sure what to suggest. Perhaps the script is somehow conflicting with something else that you've got set up.

                          Try creating a new blank database, for testing purposes, then create some empty records, then apply the OnLayoutKeystroke script trigger as before and see what happens.

                          Nick

                          • 10. Re: moving the 'record pointer' using a script trigger
                            philmodjunk

                            If you have advanced, use the script debugger and watch your script run step by step. Perhaps another script trigger is "firing" in the middle of your first script and it's got a "beep" step in it.

                            • 11. Re: moving the 'record pointer' using a script trigger
                              cmspe

                              I used the script debugger, but didn't see anything that would cause a beep.  In fact, I've never scripted a beep in any of my databases.  I don't know where it could come from.

                              • 12. Re: moving the 'record pointer' using a script trigger
                                philmodjunk

                                When you run the script with the debugger enabled, is there always a specific script step that precedes the "beep"?

                                • 13. Re: moving the 'record pointer' using a script trigger
                                  cmspe

                                  This is the only code for the layout:

                                  If [ Code (Get (TriggerKeystroke)) = 10 or Code (Get (TriggerKystroke)) = 13 ] 
                                        Go to Record/Request/Page [Next]
                                  End If

                                  • 14. Re: moving the 'record pointer' using a script trigger
                                    philmodjunk

                                    And you've got at least 3 lines to that script. Does the beep always happen at a specific point in this script?

                                    When you first press a key?

                                    When the If line is evaluated?

                                    When the script takes you to the next record?

                                     

                                    I honestly don't see how any part of that script could cause a "beep", I'm just trying to see if a specific action is the trigger. If it is, you can try performing the same action with a different button, script, layout and/or file to see if the same thing happens.

                                    1 2 Previous Next