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? (BeforeUpdate, LostFocus, SetFocus)

Status
Not open for further replies.

DahMurf

Programmer
Apr 12, 2003
44
US
(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?
 
IF you insist on multi board posting ( and I accept thare are good resons to sometimes ) then post the question in ONE place and post a LINK to it in the other boards.

That way it collects all of the responses together in one place and avoids people typing in answers on one board that has already been fully convered in another.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
I apologize I will do this in the future. I don't normally cross-post but I'm really in a jam. I wasn't getting much of a response so I thought maybe I had posted in the wrong place.

I will take your advice in the future.

Thank you!

This thread is cross posted at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top