Input Mask Error Message

P

Paul Scott

Hi all,

I have an Input Mask that requires six digits. When you
enter let then six digits you receive a generic message
box (The value you entered isn't appropriate for the
input mask....).

Is there a way to trap this error so I can setup a custom
message box?

Thanks,

Paul
 
F

fredg

Hi all,

I have an Input Mask that requires six digits. When you
enter let then six digits you receive a generic message
box (The value you entered isn't appropriate for the
input mask....).

Is there a way to trap this error so I can setup a custom
message box?

Thanks,

Paul

Here's how you can find the correct error and show you own message for
any of the form level errors.

First code the form's Error event:

MsgBox "Error#: " & DataErr ' Display the error number
Response = acDataErrDisplay ' Display Default message

Then open the form and intentionally make that error.

The message box will display the error number.

Next, go back to the error event and change that code to:

If DataErr = 2279 Then
Response = acDataErrContinue ' Don't display the default message
MsgBox "Please re-enter the correct Zip code"
Else
MsgBox "Error#: " & DataErr
Response = acDataErrDisplay ' Display Default message
End If
 
P

Paul Scott

Hi Fred,

I got the code to work but it doesn't display an error
number. All I get is "Error: ". Then the original appears.

Thanks for the help,

Paul
 
M

Michael Keating

Hi,

Have a look in the help files at the Err object. It has properties like
Number and Description, so you can use code like:

If Err.Number= 1234 then

MsgBox "That's a typo!"
Else

Dim Response As Long

Response = MsgBox("Unexpected error : " & _
Err.Number & " : " & Err.Description _
, vbCritical Or vbAbortRetryIgnore, _
"Data Error")
If Response = vbRetry Then
Resume
ElseIf Response = vbIgnore Then
Resume Next
End If

End If

which will let the user know either way.

HTH

MFK
 

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