Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change an input mask error message 1

Status
Not open for further replies.
Jan 15, 2004
5
0
0
US
Hi,
I have an input mask:00/00/0000;0;_ for users to enter date.
I also have a validation rule that it cannot be a date greater than today's date.
The validation text will only show up for if the validation rule is violated but will not show up when users don't enter the data according to the input mask.
The error message that comes up for input mask is the system error message. How can I change that?

Thanks!
 
Hi!

This kind of error, is referred to as form errors, and can be trapped thru the forms error event. In my version, it's error number 2279, but it might be something else, so to trap for it, and display a custom message, something like this might be applied to the forms on error event:

[tt]if dataerr=2279 then
msgbox "Something wrong!"
response=acDataErrContinue
end if[/tt]

The form error event has to arguments, dataerr (containing the error number) and response. acDataErrContinue means for Access to continue without showing default message box.

Should this not trap the error, try using msgbox dataerr to find correct dataerr number.

HTH Roy-Vidar
 
Hi,

I tried that and I have entered:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 2279 Then
MsgBox "Please enter the infraction date in the following format: MM/DD/YYYY", [vbokayonly], [Date Error]
Response = acDataErrContinue
End If
End Sub

However when I go and test it out it gives me an error message:
Run-Time error '2465:
Microsoft Access can't find the field '|' referred in your expression.

Am I suppose to secify a field?

Thanks!
 
Hi!

That's because of the syntax in the msgbox, here you don't really need to specify buttons of the box, but I often do so myself. If you want a title, it must either be "qualified as text" or use a variable, or a combination as shown below.

[tt]msgbox "Something wrong!",vbOkOnly,"SomeTitle " & DataErr[/tt]

More on the syntax of the msgbox in F1

HTH Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top