Resuming Default Error Handling After A Custom Response
Posted on 2002-06-18
I am using Access 97. I have run Repair Database and been told it was successful.
When an error occurs, I want to run a sub to log the error in a table of such errors and then tell Access to give the error message it would give if there were no custom response -the default error message.
The logging routine is an independent module. I have been calling it from an error handling routine triggered by On Error GoTo at the beginning of a subprocedure. The clogging routine requires a "Response As Integer" argument; I have passed 1, 0, or -1 as actual arguments from the calling routine. Near the end of the logging routine I have
Response = acDataErrDisplay
The procedure does execute pass that point(I put in a MsgBox to check). From Debug.Print it is clear that this line does change the value of the Response argument passed to the logging routine, and that it changes it differently for acDataErrContinue v. acDataErrDisplay.
If I try to enter a "Response =" in an event procedure run from a control or form event, I get "variable not defined", except in an event procedure for the form's OnError event.
When can a Response argument be used to control Access's default error messages? Is it available only in code run from a form's Error event rather than an On Error statement? If so, why?
Is there a better way to pass the Response argument to the logging routine?
What triggers a form's Error event? Can an error in the form's class module?
Is there some other statement(Resume or other) or code which I can use to log the error and then return to default error handling?
I know that I could create a custom MsgBox with the error number and description, and with the Help button through the HelpFile and HelpContextID properties. Could I also add Debug and End buttons to such a box?
But first I would like to know if there is a way to simply tell Access to give the default error message.