Unable to avoid error message

C

C J Squibb

I'm doing some data validation in an Access form and display a messag
listing any required fields that have been left blank.

The code segment ends with:

If strMissingFields > "" Then
' Missing field(s) - display the message
Msgbox ("Please enter all the required fields. The followin
are missing:" _
& vbCrLf & vbCrLf & strMissingFields)
Cancel = True
' This SHOULD cancel the BeforeUpdate event and return to th
form.
End If

This is supposed to cancel the BeforeUpdate event, and return the use
to the form to fill in the missing fields. However, I get a dialog bo
saying "You can't save the record at this time. (Database name
Database may have encountered an error while trying to save a record.
If you close this object now, the data changes you made will be lost.
Do you want to close the database object anyway?"

The form's Error event fires just before this, but when I put in
message box to give me the error number and description, it just say
Error 0.

Help!

Clair
 
S

strive4peace

Hi Claire,


since "This SHOULD cancel the BeforeUpdate event and return
to the form", you need to do that and exit ;)

after
Cancel = True

add another line -->
Exit sub

make sure you have Exit Sub before your error handler as well :)

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 

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

Top