Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation issues

Status
Not open for further replies.

DahMurf

Programmer
Apr 12, 2003
44
US
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?

 
How about setting the Locked property to YES or the Enabled property to NO on all fields you don't want the user to be able to access. Then, in the AfterUpdate event of the vehicle field you can change the Locked/Enabled property.


Randy
 
Thanks for the response. I tried it but I've found that I can't change the locked or enabled property on all the fields. Not sure why.
 
What kind of control prevents you from changing the locked and enabled properties?

Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top