Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Dec 2009
    Lincoln, Nebraska, USA
    Thanked 0 Times in 0 Posts
    I have a database that I moved to Access 2007. I did not program it, just moved it. In 2002, the Close/Min/Max buttons were not available. In 2007, they are there. This database collects alarm data for a machine and allows reports to be printed. I cannot have the operators closing down the database. I found some code on the net, but it was about 250 lines and I do not know enough yet to get it to work. Any simple way to remove these buttons?


  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Mt Macedon, Victoria, Australia
    Thanked 45 Times in 44 Posts
    This post contains some code that disables the Close button.

    You need to copy all the code into a new module, then type

    SetCloseBox False

    in the immediate window.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Brisbane, Queensland, Australia
    Thanked 1 Time in 1 Post
    If your issue is that you don't want the users to be able to quit the application then the most effective answer is to use a menu or switchboard that stays open all of the time.

    Put a checkbox control on the menu, name if chkCanClose. set its visible to false and its default to false.

    Then in the Unload event of this form, which will fire when the user tries to quit the application, in a way that you don't want them to, it will stop them.

    Private Sub Form_Unload(Cancel As Integer)
        If Me.chkCanClose = False Then
            Cancel = True ' This will cancel the closing of the form and therefore the appliation as well
        End If
    End Sub
    Then on the menu you can put a button on the Menu that sets then Can Close to true the quits the application. Or however you want to handle it.

    Private Sub cmdQuit_Click()   
        Me.txtCanClose = True
    End Sub
    This will prevent the application closing but you can use the same technique to prevent closing of individual forms as well.

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Manning, South Carolina
    Thanked 1,608 Times in 1,452 Posts
    Hello All,

    I just tried this one out and it works great. I had to do a little digging on google but I found the information I needed.

    Now I have this in my AutoExec Macro: Action: RunCode -- Function Name: SetCloseBox(False). Killing the Application level Red X.

    Then in the Open_Form() event for my Switchboard I have: SetCloseBox False, Me.hWnd. Killing the Switchboard Red X.

    That last part, Me.hWnd, I found googling is a builtin property of the Access form object that returns the windows handle for the form window that you can pass as an argument to the SetCloseBox function...sweet.

    Now the users, I have some real problem children, can't exit except by way of the selection on the Switchboard which closes the application gracefully as I intended.


    P.S. I just love the people on Windows Secrets Lounge.
    May the Forces of good computing be with you!


    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts