Prevent sending email if data on form incorrect

  • Thread starter Thread starter John K. via AccessMonster.com
  • Start date Start date
J

John K. via AccessMonster.com

I have a data entry form with a submit menu item. When the user has filled
in the data entry form, they click submit on the menu and the record is saved
in the database and an email is sent to the user.

But, when there is an error (data validation error) on any of the fields of
the form, the User gets an error pop up stating that the data is not valid
for this field, but if they ignore the error and click submit, it will send
the email anyway, but not save the record in the table.

My users are confused because they get the email, but can’t find the record
in the database.

How can I prevent the email from being sent if any of the fields on the form
has data validation errors?

John K.
 
One approach would be to put "If Me.Dirty=true then Exit Sub" at the head of
your button-click code. This will keep the message from being sent if
there's unsaved (unvalidated) data in the form.
Of course you could make it fancier by giving the user a msgbox instead
of just exiting.
 
Back
Top