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

Posted on 2006-03-30
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
    LVL 44

    Expert Comment

    by:Leigh Purvis
    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
    Sounds interesting ....

    Can you provide some details???
    LVL 44

    Accepted Solution

    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
    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
    No probs ET :-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now