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.