Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disable close button (97)

    Is it possible to disable the close button of the Access Window?

    I know how to disable the close button of a form, but is it also possible to disable the close button of the Access window.

    Bart

  2. #2
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable close button (97)

    I got this from a nice person named Neil at another Q/A site and it works for us....Hopefully, you are using VBA code for your buttons and have an Exit button, or you will get permanently stuck (I know, it happened to me). As you have indicated, you have already disabled the X button on the form.

    First of all , in the code, you need to define a variable (true/false):

    Dim fOKToClose As Boolean
    ....................
    Then you need two events on the form:

    Private Sub Form_Load()
    'set the trap, so no one can close the form without
    'clicking the Close button
    fOKToClose = False

    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    Cancel = Not fOKToClose
    End Sub

    Finally, on your exit button code, you need to reset the "okay to close" back to True before you exit. My button is conveniently named "Close"....

    Private Sub Close_Click()
    fOKToClose = True
    .....
    end sub

    Good Luck!
    Carpy Diem, it's .

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable close button (97)

    Hi, Peggy

    Thanks for the reply.
    A nice workaround, preventing closing the form and thereby preventing access to be closed.

    I still am interested in a way to disable the close button of the main MS Access MDI form.

    If someone knows how to do it, please let me know.

  4. #4
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable close button (97)

    I looked up MDI Forms in the Microsoft Knowledgebase and downloaded a sample - the sample they had was in C++ and since I don't have this installed at work, I was unable to look at the code to see if it could be adjusted. I do see your problem, though. Sorry! <img src=/S/bummer.gif border=0 alt=bummer width=15 height=15>

    Can anyone else help here?
    Carpy Diem, it&#39;s .

  5. #5
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable close button (97)

    Try Tip #19. It works like a charm.

    <A target="_blank" HREF=http://www.calvinsmithsoftware.com/cserveNew.htm>http://www.calvinsmithsoftware.com/cserveNew.htm</A>

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable close button (97)

    Thanks!

    Works great! By the way, nice set of tips, I added the site to my favorites.

  7. #7
    New Lounger
    Join Date
    Oct 2001
    Location
    Perth, Western Australia
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable close button (97)

    Thanks, mate!

    Regards
    Dean

Posting Permissions

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