Reputation: 1129
I would like to know the best way (the best event) to execute a routine upon the close of the database. Is there a way to write a routine that will execute upon closing the database even if it is closed in a non-uniform way (e.g. by clicking the 'X' in the top right hand corner of the screen) ?
Upvotes: 3
Views: 1171
Reputation: 97101
Access does not expose a database shutdown event which you can use in VBA code. You can use the close event of a form to do what you want.
Private Sub Form_Close()
MsgBox "Ciao!"
' Call YourExitProcedure()
End Sub
Of course that means the form must be open when the database is shut down. However it need not be visible. So you could open the form hidden at database start, and leave it open and hidden while the database itself remains open.
Upvotes: 6