Replace the system message on data input

  • Thread starter Thread starter Newbie
  • Start date Start date
N

Newbie

Hi,

I have a form control that is bound to a date field in a table

If the user enters data that is not in the correct format eg 050404 instead
of 05/04/04 Access returns a message - "This is not valid etc etc"
How can I replace this system message with my own message?

Thanks
 
Add code under the Form's OnError event.

If DataErr = XXXX then 'Where XXXX is the error number
msgbox "Your Own Message"
Response = False 'Cancel built in error message
End If
 
Thanks - where do I get the error no. from - the standard msgbox does not
show a number?
 
Thanks - where do I get the error no. from - the standard msgbox does not
show a number?

You have to do this in 2 steps.
First, code the Form's Error event:
MsgBox DataErr
Response = acDataErrContinue


Then open the form and intentionally make the error.
Bingo. The message box appears with the error number.
Then go back to the error event and trap that error:
If DataErr = 1234 Then
MsgBox "Please enter the date in the correct mm/dd/yy format."
Response = acDataErrContinue
End If
 
Back
Top