troubleshooting Question

Error handling is MS Access

Avatar of mlcktmguy
mlcktmguyFlag for United States of America asked on
Microsoft Access
6 Comments5 Solutions366 ViewsLast Modified:
In a given function or subroutine it is possible that multiple recordsets may be opened and closed, many variables intialized and used.

If the error handler in this sub or function is invoked it must handle 'known' errors appropriately.  In some case an unexpected error is encounter for which there is no known recovery and the only choice is to exit the app.

It's easy enough to exit the app but prior to this exit it would be much more appropriate to 'clean up' any opend object prior to the exit.  The objects in use at the time of the error are variable depending at what point in the logic the error was thrown.  I know if the sub is exectued to completion it will have used, recordsets Rs1, Rs2, Rs3 and Rs4.

When I get to the error handler some of these may have been opened and others not. The objects used in the sub or function may not only include recordsets and variable but als MS Excel that is being used to export a spreadhseet using a template, MS Outlook that is being used to generate and email and of course forms and reports.

Is there a generic way to find all open objects and close them prior to exiting the app.
Joe Howard

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 5 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 5 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros