Link to home
Start Free TrialLog in
Avatar of mlcktmguy
mlcktmguyFlag for United States of America

asked on

Error handling is MS Access

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.

Question:
Is there a generic way to find all open objects and close them prior to exiting the app.
ASKER CERTIFIED SOLUTION
Avatar of Joe Howard
Joe Howard
Flag of United States of America image

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
SOLUTION
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
SOLUTION
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
SOLUTION
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
SOLUTION
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 mlcktmguy

ASKER

All excellent answers.  I raised the points so I could distirbute more points to responders.