date validation

  • Thread starter Thread starter helena
  • Start date Start date
H

helena

I have an unbound date field that is
masked "99/99/0000;0;_" (short date). What I want is to
provide my own error message instead of using the default
system error message. Where does the error "trigger" when
an invalid date is entered. How can I bypass the system
error message and provide my own?
 
I have an unbound date field that is
masked "99/99/0000;0;_" (short date). What I want is to
provide my own error message instead of using the default
system error message. Where does the error "trigger" when
an invalid date is entered. How can I bypass the system
error message and provide my own?

Trap the error in the Form's Error event:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 2279 Then
Response = acDataErrContinue ' Don't display the default message
MsgBox "Please re-enter the correct code"
Else
Response = acDataErrDisplay ' Display Default message
End If
End Sub
 
Trapping from the Form_Error event works...thanks
My next related question is...how can I reference
the "errant" field (text box) to reset the field
to blank? There are multiple date fields on the
form.

Thanks,
Helena
 
Trapping from the Form_Error event works...thanks
My next related question is...how can I reference
the "errant" field (text box) to reset the field
to blank? There are multiple date fields on the
form.

Thanks,
Helena

Add a line of code:

Response = acDataErrContinue ' Don't display the default message
MsgBox "Please re-enter the correct code"
Me.ActiveControl = " " ' ** Add this line **
Else
etc.
 
Back
Top