Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute code upon closing database

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) ?

like image 899
Marchese Il Chihuahua Avatar asked Dec 16 '25 18:12

Marchese Il Chihuahua


1 Answers

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.

like image 146
HansUp Avatar answered Dec 20 '25 05:12

HansUp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!