Validation fail need to reset cursor to field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi I've performed validation on a field and have a MsgBox to say "invalid
part number". Need to reset the field move the cursor back to the beginning
of field and delete invalid data.

I've tried the undo method, but it seems that whatever I do the cursor moves
to the next field regardless of whether or not the validation fails.

Your help is greatly appreciated

Thanks
 
Hi Gary,

You can perform the validation during the Before_Update event procedure for
either the control, or the form, and issue Cancel = True if the validation
fails. If you cancel at the control level, focus should remain in the
control. If you cancel the form's Before_Update, you can issue a
DoCmd.SetFocus ControlName.

I don't know that I would automatically delete the invalid data for the
user; perhaps they're off by just one character of a 15 character part
number. They might get rather upset with the database developer if they
constantly have to re-enter the entire string whenever they commit a little
data entry booboo.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top