Catch Error

R

Ray Todd Jr

I have a form that is used for data entry. One of the fields is a required
field. If I tab through the field everything is ok, however, after you try
to tab through the last field, access attempts to save the record. I get the
following error (because the required field is null due to not being filled
by the user).

The field cannot contain a null value because the required property for this
field is set to True. Enter a value in this field (Error 3314).

Where and how do I attempt to trap this error so that I can give the user a
more pleasant and understanding of the error and how to resolve the issue.

Would I attach error trapping to the before update of the field in question?
Any help and suggestions appreciated.

Thanks,

Ray.
 
G

Golfinray

In your table that supplies this form (either by itself or through a query)
do you have required set to yes on that field? If so it will keep asking you
for data.
 
B

Beetle

Use the *forms* Before Update event to trap for this like;

Private Sub Form_BeforeUpdate(Cancel As Integer)

If IsNull (Me!YourControl) Then
MsgBox "You must enter a value in field X"
Cancel = True
Me!YourControl.SetFocus
End If

End Sub
 
R

Ray Todd Jr

Hey Beetle:

Of course, the forms events. It never occured to me as I was so wrapped up
with the fields events.

It worked wonderfully.

Thanks,

Ray.
 

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