Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Validating a textbox : switching forms.

Validating a textbox : switching forms.

Validating a textbox : switching forms.

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.

RE: Validating a textbox : switching forms.


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 Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close