I believe your strategy is basically correct; OnObjectExit is the correct trigger to use. What you're missing is that the script won't override the normal tab order built into the layout. Hence, the app is obeying your command to go to the correct field, but then reverts back to the default tab order. If you turn off the default tab order, you should be able to get it to do what you want.
At least that's how it works in my tests.
Mike, thanks for the quick response. Let me add a few details.
My inspection form has about 80 fields of information, so using the built-in tab order helps a lot. I understand your concept about removing the default tab order. But if I do that, then the user will not be able to use the built-in "next" button to go from the prior field to the field where my original script is running. If I continue with example above, they can't go from field 9 to field 10 using the built-in tab order and "next" button.
Though I am not going to remove all of the tab orders and make 80 custom go to scripts, I did do a test of your suggestion and it did not work. The go to field scripts fire on the onobjectmodify (if user changes a value), but not when they press the "next" button (where the script "should" run under the onobjectexit script trigger)..
Hm. Seems the tab order fires after the script, which is causing it to revert back to the original field if all the tab orders are removed. (I didn't test that.)
Okay, I played with this for a few minutes and it's doable, but it'll probably be best to change the paradigm a bit. You'll want to set up some OnObjectEnter triggers on the fields you don't want it to go to (i.e. the ones you don't want next in the tab order) in addition to (or perhaps instead of) the OnObjectExit triggers.
This will be very dependent on exactly the effect you want, but basically, if you want people to jump from field A to field B normally, unless condition C is true, what you'll want to do is say, "On entering field B, jump to field D if condition C is true." That will basically allow the normal tab order to function, but be bypassed by your trigger if the condition is true.
The downside of that is, obviously, if you should want to allow users to enter field B even if condition C is true. In such a case, you'll need to set an OnObjectEnter trigger to save the name of the last field entered (perhaps in a variable) and allow the cursor to go into that field if they came from an allowed location (instead of field A).
Hope that makes sense.
I have played around with this issue a little. Mike is right that if the trigger is OnObjectExit the tab order seems to override the script. The following script will work if it is triggered OnObjectMODIFY, but not OnObjectEXIT:
If [ "first condition" ]
Go to Next Field
Else If [ "second condition" ]
Go to Field [ yourTableName::textField 2 ]
Go to Field [ yourTableName::textField 3 ]
Thanks Mike and Keywords: Users will have to go into this field often enough, so looks like any code will not work 100% of the time. I'll stick with the original method, which is to have a separate button, between field 10 and 11, that user will press to go to area where field 15 is located. Not as elegant as automated code, but it gets a passing grade for now.