How to Disable the Close Button (X) on the Access Application Window????

Posted on 2006-03-30
Medium Priority
Last Modified: 2009-07-17
I have an Access 2k application that uses the following procedures to disable the Close Button "X" on the Application window.


This works and when I tested it on my workstation (Win XP) the Close Button "X" is disabled and when I Right Click  the application on the Taskbar the "X Close Alt+F4" is also disabled.  

I have a client that's reporting when they Right Click the application on the Taskbar the "X Close Alt+F4" is still active.  They are running Win XP as well (from the screen shot I reviewed) but I will confirm.

Any ideas or input will be appreciated.



Question by:Eric Sherman
  • 3
  • 2
LVL 44

Expert Comment

by:Leigh Purvis
ID: 16336661
Instead of fighting that - you might be as well off to just use the old "Hidden Form - set to Cancel it's Unload event".
Preventing the application from quitting until you say so.
LVL 19

Author Comment

by:Eric Sherman
ID: 16337413
Sounds interesting ....

Can you provide some details???
LVL 44

Accepted Solution

Leigh Purvis earned 2000 total points
ID: 16337599
Umm... hmm... erm...

Create a form frmNoClose.
Create a boolean variable in it's declaration section (this could be done with a texbox control too of course).
Public blnAllowClose as Boolean

It's unload even would look like

Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next

    Cancel = Not blnAllowClose
End Sub

Launch the form hidden
docmd.OpenForm "frmNoClose",windowmode:=acHidden

To allow your application to close call
Forms!frmNoClose.blnAllowClose = True
LVL 19

Author Comment

by:Eric Sherman
ID: 16337925
Thanks LPurvis ...

Since this is a Front-End with a startup form (that has a logout button) I could use the same concept on that startup form.  Just would have to use a text control (hidden) and set it to -1 to force the user to use logout button.  On the Unload Event of this form simply test the value of say TxtForceUser and if -1 Cancel Event.  TxtForceUser is set to -1 on Open and when the user clicks the logout button it is then set to 0.

This seems to work and I don't have to load the extra hidden form.

Thanks for the idea and code.....  I will award you the points.

LVL 44

Expert Comment

by:Leigh Purvis
ID: 16339482
No probs ET :-)

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question