Expanding on what Trynew suggested:
Open a form invisibly when the database starts up. In its Form_Close event procedure, put the code you need to run at shutdown. This code will be called whether the user selects File|Exit from the menu, closes the Access window, even if the user shuts down Windows without closing the database!
If you need to prevent the user from closing the database, use the Form_Unload event procedure instead. Its Cancel parameter can even be used to stop a close attempt during Windows shutdown--so be careful that you can always create the conditions that allow the close to succeed!
Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein