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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating a textbox : switching forms.

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
Form A has a textbox into which a supplier’s code is entered. The validation routine checks that it is a valid code and refreshes other interesting controls on the form.

The user may however click on another form (Form B) while txtSupp has focus. In that case FormA.txtSupp.valid() checks for that and allows focus to pass to that other form - without generating an error message for an invalid supplier.

When however the user clicks back on Form A – perhaps on a different control, I would like to continue the validation of the supplier - just as if there had been no intervening click on Form B; in that case clicking on the different control on Form would have invoked txtSupp.valid(). How can I organise that?

Thank you.
 
Andrew,

I would argue that before you activate Form B, you should complete the validation of the textbox on Form A. In other words, don't let the user go to Form B until any error in the textbox has been corrected. After all, you wouldn't move focus to another control on Form A before the texbtox had been validated. Why not the same philosophy with Form B?

That said, if you really want to do this, you could add some code to Form A's Activate event. When the event fires, check to see if the user was previously in the textbox (you presumably already have some sort of flat go tell you this). If so, set focus back to the textbox. Not only will this force the textbox to be validated, it will also be a natural thing for the user, as they will perceive that they are simply carrying on where they left off.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top