(posted in forms also but only got one response)
Here's my scenario:
User opens form.
First field is Vehicle. They MUST key a vehicle number before doing anything else.
I have code in the BeforeUpdate of the Vehicle field. It works fine. The user cannot leave
The field without entering a valid value.
I have the same code in the LostFocus of the Vehicle field. I did this in case they tab past the field without entering a value.
In both sets of code I set focus to a different field and then back to the vehicle field. This puts the focus back to the vehicle if they have tabbed or moved elsewhere.
I am sometimes getting the following message when tabbing out of the field:
Run-Time error ‘2108’:
You must save the field before you execute the GoToControl action,
The GoToControl method, or the SetFocus method.
Question #1: Is there some kind of test I should do to determine if I should execute the SetFocus command?
Question #2: You may have guessed, the code works great except that I can not leave the form. So if I’ve opened the form by accident I can’t cancel and close without entering a valid vehicle number. I have a cancel button but the field validation happens first, which gets me stuck in the field. Any suggestions?
Here's my scenario:
User opens form.
First field is Vehicle. They MUST key a vehicle number before doing anything else.
I have code in the BeforeUpdate of the Vehicle field. It works fine. The user cannot leave
The field without entering a valid value.
I have the same code in the LostFocus of the Vehicle field. I did this in case they tab past the field without entering a value.
In both sets of code I set focus to a different field and then back to the vehicle field. This puts the focus back to the vehicle if they have tabbed or moved elsewhere.
I am sometimes getting the following message when tabbing out of the field:
Run-Time error ‘2108’:
You must save the field before you execute the GoToControl action,
The GoToControl method, or the SetFocus method.
Question #1: Is there some kind of test I should do to determine if I should execute the SetFocus command?
Question #2: You may have guessed, the code works great except that I can not leave the form. So if I’ve opened the form by accident I can’t cancel and close without entering a valid vehicle number. I have a cancel button but the field validation happens first, which gets me stuck in the field. Any suggestions?