Execute code after closing database

I would like to know the best way (best event) to execute the procedure when closing the database. Is there a way to write a procedure that will execute when the database is closed, even if it is closed unevenly (for example, by pressing the "X" in the upper right corner of the screen)?

+3


source to share


1 answer


Access does not display the database shutdown event, which you can use in VBA code. You can use the form close event to do what you want.

Private Sub Form_Close()
    MsgBox "Ciao!"
    ' Call YourExitProcedure()
End Sub

      



Of course, this means that the form must be open when the database is closed. However, this should not be visible. Thus, you can open a form that is hidden when the database starts up and leave it open and hidden while the database itself remains open.

+6


source







All Articles