Discussion Locked

VB6: Exit out of a text box's Validation

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
If a user has clicked on the New button, he will be taken to a data entry form. Most of the text boxes have simple validation's in their respective Validation events, such as to make sure they have entered something in required fields. I want the user to be able to, at any time during entering a new record, to change their mind about entering a new record and hit the Cancel button, thereby clearing the form. But I can't get the validation to end if they hit the Cancel button, even if I set CausesValidation = False in the cmdCancel_Click event. It is stuck in the Validation event and won't move on to cmdCancel_Click unless the user enters some dummy data first.

2 replies

by oliver w.

The best solution (and a very clean one too) is to validate the entries only on pressing Save/Ok.
You just have to write a function to verify all fields and returning true if the entries are valid. If one isn't valid, return the field name and senda message to the user to enter the proper values.
Especially when users want to look up special entries in different locations it is annoying to get a NOT VALID message every time.
Validating on OK/save_click is the best solution

hope that helps
Oliver

This discussion is closed to new replies.