The way this is usually done is to open a form when your application starts up and keep it open the entire time the user is in the application. Then you can put code in the close or unload event of that form, so that the code will always run when the application is closed.
Most often this form is made invisible. It may be your switchboard form that just goes invisible instead of closing when you go to another form.
A nice benefit of this is that you can trap for users trying to close the application by closing Access, and force them to close the application in an orderly fashion. All you have to do is make it so that clicking the quit button on your switchboard form changes the value of a hidden control on that form, and the close/unload code you use to shut down the application doesn't allow you to close the form unless that invisible control has a particular value.
Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.