Link to home
Start Free TrialLog in
Avatar of CaseCounter
CaseCounterFlag for Canada

asked on

Resuming Default Error Handling After A Custom Response


     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.

CaseCounter
ASKER CERTIFIED SOLUTION
Avatar of dovholuk
dovholuk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CaseCounter

ASKER

With Thanks

           The information didn't provide as simple and easy way to do everything that I had hoped for, but it was very helpful, including the information about the On Error event.

          One further question about that. Is it possible to trap a specific description rather than "Application-defined or object-defined error" for the errors that trigger it? The Access Help says that this category includes "host-created" errors like those in visual basic caused by forms, reports etc. The Err object seems to contain only Visual Basic(and some DAO) errors. Is there a way to get at the messages Access provides for form and control errors?

                                              Yours Sincerely,
                                                       CaseCounter




Avatar of dovholuk
dovholuk

>The information didn't provide as simple and easy way to do everything that I had hoped for
i understand. unfortunately, sometimes the answer to a problem is NOT the answer people want to hear. sounds like this is the case... sorry.


i don't know how to access the form level errors. all i can tell you is to set the response to 1, and it'll display the "stock" error. but i bet you knew that.

dovholuk
Thanks. I'm not sure anyone could have completely solved my problem, but you did clarify the situation a great deal.

               Counter