8 Replies Latest reply on Jan 17, 2011 3:53 PM by NickJ72

    Jumping to records alphabetically within a found set

    NickJ72

      Title

      Jumping to records alphabetically within a found set

      Post

      I need to find a quicker way to navigate records in my student database. Rather than clicking forward one record at a time to find a student's record, I want to be able to jump to the student's surname by initial letter without constraining the found set. In other words, having the alphabet A-Z on my page and clicking, for example, 'S' to jump to the start of surnames beginning with S. It would then be much quicker and easier to find the required record.

      What is the best way to achieve this?

        • 1. Re: Jumping to records alphabetically within a found set
          philmodjunk

          Set Variable [$Letter ; Value: Get ( ScriptParameter ) ]
          Go to Record/Request [First]
          Loop
            Exit Loop If [ $Letter > Left ( YourTable::StudentLastName ; 1 ) ]
            Go To Record /Request [ Next ; exit after last ]
          End Loop

          You can use this same script with all your buttons, just set each one to pass a different letter of the alphabet as its script parameter. (The exit after last parameter is not really needed, it just avoids an infinite loop if you make a mistake in passing the script parameter or in setting up the Exit Loop step.)

          • 2. Re: Jumping to records alphabetically within a found set
            NickJ72

            Thanks for the quick reply. However, I'm a total novice at this kind of scripting so I wonder if you could clarify where exactly I substitute the letter I'm jumping to.

            I'm setting the jump to letter 'E' as a test, this is a screen shot of how I've interpreted your script. I've done something wrong as it's currently jumping to the last record. This is my adapted script:

            Set Variable [$E; Value:Get ( ScriptParameter )]
            Go to Record/Request/Page [First]
            Loop
              Exit Loop If [$E > Left ( Students::LastName ; 1 )]
              Go To Record/Request/Page [ Next ; exit after last ]
            End Loop

            • 3. Re: Jumping to records alphabetically within a found set
              philmodjunk

              I'd keep this script step:

              Set Variable [$Letter ; Value: Get ( ScriptParameter ) ]

              as written. $Letter is a variable that can hold any letter of the alphabet. The letter it holds depends on the letter passed to the script as a script parameter.

              Here's how you set up your buttons.

              Place a button on your layout.

              In button set up, select the perform script option and specify the above script as the script to be performed when the button is clicked. WHen you click the specify button to select a script, a new dialog opens with a text box at the bottom titled "Optional Script Parameter". Type an "A" into this box. Now when this button is clicked the script is performed and the first record where last name starts with A becomes the current record.

              Now place a 2nd button on your layout. Use button setup to select the same exact script, but now type a "B" in the Optional Script Parameter box. When you click this button, the first record where last name starts with "B" will become the current record. (You can actually copy and paste the first button, or ctrl-drag (option-drag on macs) a button to make a copy of it then specify a different letter for its parameter and use the text tool to change the button's text as needed. This gives you a series of buttons with identical size and appearance for better uniformity.

              • 4. Re: Jumping to records alphabetically within a found set
                NickJ72

                Aaarrgghh, now nothing happens at all!

                • 5. Re: Jumping to records alphabetically within a found set
                  philmodjunk

                  You changed two steps from what I had in the original script:

                  Set Variable [$E; Value:Get ( ScriptParameter )]
                  Exit Loop If [$E > Left ( Students::LastName ; 1 )]

                  Make sure that both of these steps use exactly the same variable name or you will end up on the last record every time.

                   

                  • 6. Re: Jumping to records alphabetically within a found set
                    NickJ72

                    The script now reads:

                    Set Variable [$Letter; Value:Get ( ScriptParameter )]
                    Go to Record/Request/Page [First]
                    Loop
                      Exit Loop If [$Letter  Left ( Students::LastName ; 1 )]
                      Go To Record/Request/Page [Next; Exit after last]
                    End Loop

                    Buttons A-Z are set to execute the script, each with the relevent A-Z Optional Script Perameter. But all buttons are now jumping to the first record by surname, "A".

                    I'm very confused!

                    • 7. Re: Jumping to records alphabetically within a found set
                      philmodjunk

                      How silly of me. My mistake there.

                      Change this line to:

                      Exit Loop If [$Letter < Left ( Students::LastName ; 1 )]

                      • 8. Re: Jumping to records alphabetically within a found set
                        NickJ72

                        Brilliant! That's done it. Thank you!! :-)