I have a form field called "claim number" that must be entered before a user can continue to add a new record using a multi-tab form. I'm using the on lost focus event of the text box to ensure they enter a value. I also want to enable a user to cancel an update and close the form using a command button, which if can't do using the lost focus event. Any suggestions on what textbox event I should use to validate data entry? I want to validate that something has been entered before they move to another field or tab but also give them the ability to cancel and close the form.
This conversation is currently closed to new comments.
Save you self a world of hurt. put a form in to collect claim number enable OK and that passes it in to your current form and displays it read ony if required.
Other options would be Can you check waht has focu and then skip the validation e.g
If ((!CancelButton.HasFocus) && (InvalidClaimNumber)) Showerror("You must enter a valid claimNumber") ClaimNumberBox.Focus
Or some such.
to write your validation and call it (except on Cancel button etc) when that gains focus if it , fails show a dialog or something and the put the focus back to teh claim number box.
Careful how you do this sort of thing, lost focus can be fired when you switch application, or show a dialog and such. Sometime windows just swalows it and never fires the event as well.
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
Field Validation - Access 2007