I would like to run code when the user presses the X button. I've read that the only way to do this is is to load a hidden form during StartUp (AutoExec) and put the code on the Unload event of that form. (Also it has been mentioned that this can potential not work in certain circumstances.)
Is this true..... this is the only way? I just can't believe it.... so making sure.
I would like to run Ghudson's code on close. Nice work Ghudson
Is this true..... this is the only way? I just can't believe it.... so making sure.
I would like to run Ghudson's code on close. Nice work Ghudson
Code:
Public Function CompactOnClose()
On Error GoTo Err_CompactOnClose
If FileLen(CurrentDb.Name) > 5000000 And CurrentUser <> "programmer" Then '5 megabytes
Application.SetOption ("Auto Compact"), 1
Application.SetOption "Show Status Bar", True
vStatusBar = SysCmd(acSysCmdSetStatus, "The application must be compacted, please do not interfere with the Compacting process!")
Else
Application.SetOption ("Auto Compact"), 0
End If
Exit_CompactOnClose:
Exit Function
Err_CompactOnClose:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_CompactOnClose
End Function