Run a Command on Close

Novice1

Registered User.
Local time
Today, 10:51
Joined
Mar 9, 2004
Messages
385
I want to delete a record when the user quits the database.

If the user exits the program normally, no problem, but if the program is closed by right clicking the Access icon on the taskbar (bottom of the screen), then the command will not be run.

Is there something like Autoexec (commands run when opened) but when the program is closed?
 
You could create a form and put the delete record in the form's unload event. Then open this form in the Autoexec as hidden. Then you can put the delete record in this form's unload event which seems to fire no matter how Access is closed. The attached database demonstrates this idea.

One thing that's a pain in the butt is that the unload event fires when you go from form view to design view so that action would delete the record too. You just have to remember not to do that. If you need to alter the design of the form you need to close it and then open it in design view from the navigation pane.
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom