How can I disable the Microsoft Access close button?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When developing forms in Microsoft Access, I typically include a "Close"
button which enables me to perform housekeeping code when exiting a form. I
disable the close button [x] in the form's title bar so that the housekeeping
cannot be bypassed. However, I have not found a way to disable the button in
the Application title bar that exits Microsoft Access, consequently have had
problems with users "taking the easy way out" by quiting the application. I
am currently using version 2003, but have lived with this problem through all
versions since version 97.
Is there a way to disable the Microsoft Access close button?
 
Barry Daniell said:
When developing forms in Microsoft Access, I typically include a "Close"
button which enables me to perform housekeeping code when exiting a form. I
disable the close button [x] in the form's title bar so that the housekeeping
cannot be bypassed. However, I have not found a way to disable the button in
the Application title bar that exits Microsoft Access, consequently have had
problems with users "taking the easy way out" by quiting the application. I
am currently using version 2003, but have lived with this problem through all
versions since version 97.
Is there a way to disable the Microsoft Access close button?

You can open a hidden form at startup with the following code in its Unload
event.

If OkToClose = False Then
MsgBox "Please use my close button"
Cancel = True
End If

In your close button code...

OkToClose = True
DoCmd.Quit


You should however be able to simply put any house cleaning code in the
appropriate Close or Unload events of your forms and let the users utilize
the standard [X] boxes.
 
Hi Barry,

I use these techniques. They work just fine.
Take your pick based on version.

ACC: How to Disable the Close Button (X) on the Access
Application Window (95/97)
http://support.microsoft.com/?id=258049

ACC2000: How to Disable the Close Button (X) on the Access
Application Window
http://support.microsoft.com/?id=245746

ACC2002: How to Disable the Close Button (X) on the Access
Application Window and the Exit Command on the File Menu
http://support.microsoft.com/?id=300688

Alternatively, take a look here:

http://www.mvps.org/access/general/gen0005.htm

Hope that helps,
 
Back
Top