How can I over-write the system error
message of a form?
I set all the fields in my form as required.
So when someone skips a field, the form
will prompt a system error message as it
is a required field. How can I do to have
my own error message?
Unfortunately, it isn't just a matter of "overwriting the system error
message." You will need to include error handling, and if you include some,
you really need to include error handling everywhere in the application.
Here is some basic generic error handling code that, at least, informs the
user that there has been an error and which error it was:
Immediately after the Sub or Function line:
On Error GoTo Err_Proc
then at the very end of the Sub or Function, just before the End Statement:
Exit_Proc:
Exit Sub 'or Exit Function, as appropriate
Err_Proc:
MsgBox "Error " & Err.Number & " : " & Err.Description,,"Title of your
choice"
Resume Exit_Proc
Immediately after Err_Proc, you add code to handle specific errors... you
can, in fact, deal with some errors and just continue.
You can also add error logging, and other niceties.
An non-specific error associated with a Form itself will cause the On Error
event for that Form to be raised, so error code to handle those errors is
coded in the Form's OnError.
My guess is that the error you describe may be raised in the BeforeUpdate
event of the Form. Once you know the Error Number, and where it occurs, you
can put it code to handle that, and give the user a polite error message
crafted for the user's knowledge level.
Larry Linson
Microsoft Access MVP