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.
 

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

Similar Threads

How to validate a date entered on a form 2
Date Mask auto changes 1916 to 2016 2
Input Mask 1
Date 4
Data Entry Form 3
Input Mask 2
Pulling dates 2
Date Input Mask and Value 2

Back
Top