I believe if you exit your script with a 0, or "false", the tab switch will not proceed. If you don't exit with a false result, then right after going to the tab you want them on, it'll go to the tab they clicked.
1. 0 or false: I don't understand where my script would set such a value? Is it just implied by one of the field being empty?
2. What's the reason behind '0 or false' value causing the script to be ignored and tab choice prevailing?
Put inside your IF statement "Exit Script [False]" This prevents the script from exiting and finishing the action (in this case switching from one tab to another). Thus the tab wont switch.
Well not exactly. The SCRIPT finishes but the triggering event (user attempt to switch tabs) does not.
Might be easier to imagine this for on object keystroke event. You type in a field that has on object keystroke script trigger. Your handler script looks at the input (keystroke). Say you are only allowing numbers In the field but user typed W. Your handler script exits false and the W does not get passed to the field.
Bruce: Thanks. Makes a bit more sense.
Jeremy: Just tried that but without success. Aside from my wish to prevent users moving off this tab before completing certain fields, there is a problem that as soon as I perform any script on this tab, I get moved to the default tab. I remember setting the latter as a 'default front tab' way back, but now that I'm using scripts it is a right nuisance that all roads immediately lead back to that front tab.
""Just tried that..."
But where is the script?
i Suggest you post an example file, it can be a simplified version of what you are doing.
Note carefully that all your IF tests only look at the last name field.
Sorry. All your IsEmpty tests point to LastName.
And note to admins here, we STILL cannot edit a post.
And this statement doesn't work either.
If [ IsEmpty ( Patient::Lastname or Patient::Firstname or Patient::BirthDate or Patient::Sex ) ]
If [ IsEmpty ( Patient::Lastname) or isEmpty( Patient::Firstname) or isEmpty( Patient::BirthDate) or isEmpty(Patient::Sex ) ]
Commit Records/Requests [ No dialog ]
IsEmpty ( Patient::Lastname
or isEmpty( Patient::BirthDate)
or isEmpty(Patient::Sex )
Show Custom Dialog [ Title: "Complete patient info"; Message: "You must complete critical fields before leaving this tab:" &
isEmpty(Patient::Sex ) ; "Sex"
Default Button: “OK”, Commit ]
Exit script [ False ]
Go to Object [ Object Name: "tab_default" ]
Bruce: Thanks for all the info and script and correcting my syntax error. Your script hasn't solved the problem, but I think there must be something else inhibiting it.
The tab I keep getting moved to 'A' was default front tab. I just changed this to 'B', the tab you wrote a script for. However, I can still move to 'A' even when critical fields on 'B' are blank. Furthermore, when I come from another layout, I still land on tab A, not B the one that's now supposed to be front tab.
I've checked for scripts attached to tabs, but there doesn't seem to be anything that would do the above.
Post a file.
No, you cannot move to another tab if you have followed the instructions.
That's why it is important for you to post a file so that we can see what you are actually doing instead of spending a lot of time trying to guess.
A clone of your production file would be great but I recognize you may not want to do that.
You can build a simple demo file pretty easily to show what you are actually doing.