AutoExec but is there an AutoCloseExec?

ions

Access User
Local time
Today, 08:22
Joined
May 23, 2004
Messages
823
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

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
 
Hello

Yes. put your code on the ONCLOSE event of your form.
Regards
Mark
 
close X

I prefer to disable the applications control box X button so that the user has to use my "Exit" database command button when they want to close the application.

Enable/Disable The Control Box X Button

:cool:
 

Users who are viewing this thread

Back
Top Bottom