Error Handling Idea

  • Thread starter Thread starter Kay
  • Start date Start date
K

Kay

Hi I have incorporated error handling at form level but
now I am using the run time version of access I would
like to change my code to say in each procedure the
following .....

On Error GoTo Error_Handler

In Error_Handler i would have something like

Error_Handler:

Call procedure in standard module

This would then tell the error to not show any message
but continue (simulate button selection "End"), then to
show a message "An Error Occurred in the database please
inform the administrator" the application would then quit
using -

DoCmd.Quit but log the error in a log file using
application path as the location for the log file.

I would like to include as much information about the
error as possible. Error number, Description, Date,
Specific Line of Code copied to the log instead of having
to write line numbers into the code.

Any ideas on how I can do this sort of thing would be
great!

Thank you for reading all this on your sunday afternoon.

Kay
 
Afraid that the only way to get line number is to write the line number in
the code yourself. However, assuming you're using Access 2000 or newer,
there's a great free add-in that you can use to put the numbers in your code
(and much, much more) http://www.mztools.com

My recommendation would be to write your error handler as a separate sub
that you call from each error handler. Pass the Err object to that sub, and
you'll have all of the information you need. You can use the Open statement
to open a text file for output, the Write # statement to output the data,
and then the Close statement once you've written it. (Make sure you open,
write and close all together, rather than opening the file once and keeping
it open)
 
Back
Top