If it is always tab 3 you want open you can make it the default tab.
If it will be 'the last tab you happened to be on when you left' you will need to name the tab, capture the name as you exit, and GoToObject [ThatTabName] as you return to the layout. You could do that with a OnLayoutLoad script, presumably.
This also works in FileMaker 12....
Enter layout mode. For each tab panel:
Click it twice so that a specific panel in the tab control is selected. Enter an object name for that panel in the "name" box on the inspector's position tab.
When leaving the layout, have your script save the current tab panel's object name in a global variable (let's call it $$CurrentPanel.
When returning to the layout, have your script use Go to object [$$CurrentPanel] to re-select the tab panel.
This part works in FileMaker 12, but 12 has new features that could be used to do the same thing much more simply:
To keep track of the current tab panel, use the Tab control's onObjectModify trigger to perform this script:
If [ GetLayoutObjectAttribute ( "FirstPanelObjectNameHere" ; IsFrontPanel ) ]
Set Variable [$$CurrentPanel ; Value: "FirstPaneObjectNameHere" ]
Else IF [ GetLayoutObjectAttribute ( "2ndPanelObjectNameHere" ; IsFrontPanel ) ]
Set Variable [$$CurrentPanel ; Value: "2ndPaneObjectNameHere" ]
Else If [//and so forth for each tab panel...
The above answers are great, but I'd like to offer the perhaps unhelpful suggestion of "don't switch layouts." For example, if you're writing a script that needs to visit another layout briefly and then return to where it started, and the problem is that the active tab is being reset when the script runs, then just make the script open a temporary window, do what it needs in that window, and close the window when it's done. (To avoid screen flicker, you can open the temporary window waaay off-screen, like at left = -10000.)
This isn't a great solution in every case, but I've found a lot of tab mischief can be avoided by avoiding making a script change the layout in the user's active window.
Thanks all... Very helpfull stuff.
1) If I write the script in FM11... will it be re-written by FM12 to take advantage of the new script commands?
2) Also... my file runs in "full screen" size... and I have a script that opens a smaller window... But when the smaller window opens it causes the entire file to exit "full screen" mode. How can I keep "full screen" active?
1) you'd need to modify the script yourself, but the original will work after conversion.
2) Dillik's suggestion is an excellent ida for Mac users but for you and I on a windows system with maximized windows, the automatic resize of the original window makes it a less than optimum option--which is why I didn't suggest that one--preferring to suggest a solution that works equally well on both platforms.
Thanks... but still looking for a way to keep my file maximized while it opens a smaller window.
Example... My contacts layout has a "Notes portal"... When I add a new note, a seperate "Notes layout" opens and remains open untill user presses "close"... Then the first few words of the note show up in the Contacts "notes portal".
Contacts should always remain maximized... but the Note entry layout should be a smaller "floating" window that remains there till its closed.
It's all working except that when the smaller "Notes layout" opens it causes my "Contacts layout" to exit full screen.
Hmm, I didn't realize that solution wouldn't work in Windows. So when you open a new window, it knocks you out of maximized mode? That sounds frustrating.
What about if you have a tab nested in another tab? Will this also work for that? Because I am yet to find a solution that will!
-> Fiona - yes, naming the tab inside the tab and capturing the name (even as a script parameter) works perfectly.