Catch Error

  • Thread starter Thread starter Ray Todd Jr
  • Start date Start date
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.
 
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.
 
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
 
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.
 
Back
Top