Input Mask Errors

N

N. Cotton

I have an an input mask "00/00/0000;0;_" set for a date field.

If the user inputs incorrectly - ie leaves a number off the 4 digit year,
is there a way that I can jump in with my own error message before the
default "The value you have entered isn't appropriate for the input mask
"00/00/0000;0;_" specified...

I have tried the events but not occur before the default error message
appears.

TIA
 
N

N. Cotton

You can trap input mask violations and substitute your custom error message
for the generic error message in the form's Error event:

Private Sub Form_Error (DataErr As Integer, Response As Integer)
Const INPUTMASK_VIOLATION = 2279
If DataErr = INPUTMASK_VIOLATION Then
MsgBox "There was an input mask violation!"
Response = acDataErrContinue
End If
End Sub
 
A

Allen Browne

You can trap the message in the Error event of the Form.

It's not very specific though, so you will have to figure out it it is
Form.ActiveControl or if the value was assigned programmatically.

Input masks generally do little more than annoy good data entry operators by
slowing them down, i.e. they must enter every digit, cannot insert missing
digits, and so on. It might be better to skip the input mask, and use the
control's BeforeUpdate event to check the range, e.g.:
If Me.MyDate < #1/1/1980# Then
If MsgBox("That long ago?", vbYesNo+vbDefaultButton2) <> vbYes Then
Cancel = True
End If
End If
 

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