Incorrect Date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a date field that displays something like 04/13/06. If someone enters
04/31/06 it generates a generic error response "The value you entered isn't
valid for this field."

If someone enter an incorrect date like this Is there anyway to code a
custom message?

Thanks,

Paul
 
I have a date field that displays something like 04/13/06. If someone enters
04/31/06 it generates a generic error response "The value you entered isn't
valid for this field."

If someone enter an incorrect date like this Is there anyway to code a
custom message?

Thanks,

Paul

Here's how you can find the correct error and show your 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 and the default error
message.

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

If DataErr = XXXX Then
Response = acDataErrContinue ' Don't display the default message
MsgBox "Please enter the correct date."
Else
MsgBox "Error#: " & DataErr
Response = acDataErrDisplay ' Display Default message
End If

where XXXX is the error number.
 
Thanks that's what I was looking for.



fredg said:
Here's how you can find the correct error and show your 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 and the default error
message.

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

If DataErr = XXXX Then
Response = acDataErrContinue ' Don't display the default message
MsgBox "Please enter the correct date."
Else
MsgBox "Error#: " & DataErr
Response = acDataErrDisplay ' Display Default message
End If

where XXXX is the error number.
 

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

Back
Top