Abort Insert....

Chatbox

Registered User.
Local time
Today, 03:04
Joined
Aug 30, 2004
Messages
68
I have a form that is bounded to a table, and is set to allow addition only.

When the form is open, and when user had typed data in certain fields, the record will be inserted into the table upon closing of the form.

The problem is this (example): 3 fields. All are needed to have data. User typed data in 2 of the fields and left one field blank. Upon closing of the form, it tries to insert the data into the table (but failed of course)...but this causes an error and produce a message box.

Is there any way that I can write some VBA to check the fields upon closing...and abort/skip the insertion by VBA?
 
Use the BeforeUpdate event of the form for your code that checks the data. If there is an error, you will need to cancel the update by using the following statement:

Cancel = True
 

Users who are viewing this thread

Back
Top Bottom