9.6. Issues in Error Handling

Some developers try to enhance their error handling with writing log files or sending e-mail. There are some issues involved with these error-handling techniques, as explained in the following sections.

9.6.1. Don't Use Error Handling with Logging

Some developers write code to insert an error log record into a table or text file when an error occurs. The idea is to be able to analyze when and where errors have occurred by querying this table long after the errors happened. However, this technique has some issues.

  • Access does not provide a way to determine the name of the procedure that is currently running. Because any error logging routine needs to know which procedure caused the error, you need to manually code the name of the current procedure into each error routine. That is labor intensive and prone to errors.

  • The benefit of error logging is questionable because few errors should be happening after your code has been tested and delivered. Errors should be rare enough that your users will let you know when they happen. You can always ask them to capture a screenshot if you want to see the details.

  • Some types of errors cause the attempt to log them to fail. Examples include loss of network connectivity, and disconnected storage hardware. Your user may see additional unrelated errors, or you could be lulled into thinking that all errors are logged, when they may not be.

If your code is running in a managed environment, it may be beneficial to log ...

Get Access™ 2007 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.