6 Replies Latest reply on May 2, 2012 10:03 AM by philmodjunk

    Determining what Tab you have open

    cowtrax

      Title

      Determining what Tab you have open

      Post

      I have a tab set up with 5 tabs.  Based on which tab is open, I want to use a button at the top of the screen to go to separate layouts.  Is there a way to determine which tab is currently selected so as I can perform a conditional action (go to different layout) based on the results?

      thanks.

        • 1. Re: Determining what Tab you have open
          philmodjunk

          Yes this can be done, but the script needed in FileMaker 11 will be much longer than the script you can use in FileMaker 12 thanks to some new capabilities released with that version.

          What version are you using?

          • 2. Re: Determining what Tab you have open
            cowtrax

            version 12

            • 3. Re: Determining what Tab you have open
              philmodjunk

              Enter layout mode and use the Nam box in the inspector's postion tab to give each tab panel an object name. For simplicity sake, give them object names that are exactly the same as the layout names to which you want your button to take them.

              USe the new script trigger for tab controls: OnTabSwitch with a new get function to extract the object name of the current tab panel and store it in a global variable:

              Set variable [$$CurrentTab ; value: Get(TriggerTargetTabPanel)]

              Also use the onRecordLoad trigger to perform a script that sets $$CurrentTab to the object name of the default tab panel.

              Now your button's script can be:

              Go to Layout [$$CurrentTab ] //use the "Layout name by calculation" option.

              • 4. Re: Determining what Tab you have open
                cowtrax

                When I do the Get(TriggerTargetTabPanel) command it puts the tab number (ie 1,2,3,4,5) into the $$CurrentTab variable, not the object name.  So I moved the appropriate layouts to be the first five layouts.  It not as good as if it was the object name but it works.  What command puts in the actual object name name?

                When I return from adding a new record, the $$CurrentTab variable is set to zero even though i do a refresh screen and then also do the script to reload $$CurrentTab.  In order to get the variable loaded again, i have to click on tab 2 and then go back to one.  Not a great solution.  Am I putting the refresh in the wrong place? 

                • 5. Re: Determining what Tab you have open
                  cowtrax

                  I did find a fix to it by setting up another variable and setting equal to the $$CurrentTab when I leave the first screen.  I then set the $$CurrentTab equal to the saved variable when it comes back.  I does work but I would like to use the object names rather than layout number.

                  thanks.

                  • 6. Re: Determining what Tab you have open
                    philmodjunk

                    The value of a global variable (must have two dollar signs to start the name of the variable), the value should not change unless a set variabler step or calculation with Let specifically changes it.

                    I should have either read the help file more carefully or tested my suggested fix. The Get(TriggerTargetTabPanel) returns a 2 value list, the index number of the tab followed by its object name.

                    Thus we can use GetValue ( Get(TriggerTargetTabPanel) ; 2 ) to refer to the object name of the newly selected tab panel.