You have your application open a hidden form when it starts up (either in
Startup options, or from the first form that is opened automatically). Put
hte "shutdown" code in this hidden form, in its Unload event. When ACCESS is
shut down, this form's code will run when the form is being unloaded.