First make sure that each tab has an object name. This is done using the Name box on the Inspector's position tab.
Then use OnObjectModify on the tab control to perform the following script:
#FirstTab, SecondTab and ThirdTab are object names of tabs in the tab control
Set Variable [ $TabObjects ; Value : List ( "FirstTab" ; "SecondTab" ; "ThirdTab" ) ]
Set Variable [ $$CurrentTabObject ; "" ]
Set Variable [ $I ; Value : $I + 1 ]
Exit Loop If [ $I > Valuecount ( $TabObjects ) or Not IsEmpty ( $$CurrentTabObject ) ]
Set Variable [ $$CurrentTabObject ; If ( GetLayoutObjectAttribute ( GetValue ( $TabObjects ; $I ) ; "IsFrontPanel" ; GetValue ( $TabObjects ; $I ) ) ]
Upon returning to this layout, use Go To Object [ $$CurrentTabObject ] to select the correct tab.
Note, this is not the only way that works, but makes it easy to add/change tab object names by editing the values in the first Set Variable step. You can also modify this script to pass the tab object names as a script parameter which lets you use this script with more than one tab control if you want.
Code worked great with the exception that FMP 10 doesn't recognize the attribute "IsFrontPanel". I had to write "IsFrontTabPanel" for it to work. Thanks so much.
"IsFrontTabPanel" is the correct name for FileMaker 11 as well. That was a typo on my part.
I'm trying to get this script entered in to FileMaker but have run in to a problem in the script editor. When I paste
If ( GetLayoutObjectAttribute ( GetValue ( $TabObjects ; $I ) ; "IsFrontPanel" ; GetValue ( $TabObjects ; $I ) )
in to the script editor and click on "OK" FileMaker tells me "There are too few parameters in this function." and won't let me save. Any ideas what I'm doing wrong?
Thanks. I put a ) after "IsFrontTabPanel" and it works perfectly. Thanks.