Error Trapping on a Form

"The Value You Entered Isn't Appropriate For This Field" Example

Sunday, December 29, 2002 00:31:51
home

When designing an input mask on a form, it's common for it to default to giving the following error message (or one very close to it) if a user exits out of the form without completing a valid entry:

The value you entered isn't appropriate for this input mask "'TUC"00\-AAA;0;_' specified for this field.

I find this to be undesirable, especially if the user has entered a partial entry and then decides they simply want to get out and go somewhere else in the database anyway. The above situation will commonly trap them--or at least it appears to.

The following code was suggested in a past newsgroup; it's assigned to the FORM's "on error" event procedure:
Sub Form_Error (DataErr As Integer, Response As Integer)
If DataErr = 2113 Then DoCmd Beep
Response = dataerr_continue
End Sub

I had to modify it slightly to make it work for me; mainly the error number I had for this situation was different (mine was 2279 vs 2113):

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 2279 Then
DoCmd.Beep
Response = dataerr_continue
End If
End Sub