Results 1 to 15 of 15
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Preventing CLosure (Access 2000 SR1)

    How can I temporarily prevent the user from being able to close Access (disallowing them to click on the X or choosing the Exit option from the File menu)?

    James

  2. #2
    New Lounger
    Join Date
    Feb 2002
    Location
    Netherlands
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preventing CLosure (Access 2000 SR1)

    On the main-form of your dbase, put an on-close event and use a global boolean-variable to check if you really want to quit the form or not. Cancel the on-close event on false.

    rettnuc.

  3. #3
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preventing CLosure (Access 2000 SR1)

    And what is the code to actually cancel the event?

    I am saying
    Cancel = True
    and it does not work.....

    James

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Preventing CLosure (Access 2000 SR1)

    The OnClose does not have a Cancel facility.
    However the OnUnload event certainly does. I have tried it by unconditionally setting Cancel to True and I cannot get out of my database.
    HTH
    Pat

  5. #5
    New Lounger
    Join Date
    Feb 2002
    Location
    Netherlands
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preventing CLosure (Access 2000 SR1)

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

    Edited by Charlotte to activate link

  6. #6
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preventing CLosure (Access 2000 SR1)

    Thanks is works!

    But now it causes another problem.....

    If I get this form to open another form (and all of my forms are modal to help prevent the users from causing problems) and I try and close Access by clicking on the X, I do not get any response from the program if I click on one of the radio buttons or check boxes or combo box or command button.
    I am able to navigate through the Access Menu items, but none of the menu will actually run.

    Any ideas?

    James

  7. #7
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preventing CLosure (Access 2000 SR1)

    Thanks for the link.

    It seems like I am not making myself totally clear and this only does half the job.

    It is true that this prevents Access from closing and that is what I am looking for.
    But if I have any other forms that are open, Access would attempt to close them and I want to prevent that as well.

    In essense, I want to be able to disable the X button for Access totally so that the option is not even there. I have now implemented the suggestions made here and it only properly works if the Main form is the only one open. If I have any other forms open, the program does not allow any selection of anything giving the impression of the program hanging as I have code which only allows the form to close if I click on a certain command button.

    Any suggestions here?

    James

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Preventing CLosure (Access 2000 SR1)

    Modal forms don't allow you access to the menubars, only to objects contained within the form.
    Charlotte

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Preventing CLosure (Access 2000 SR1)

    This is not an Access operation, it is something that can only be done--if at all--through use of the Windows API. I know this has been discussed before, so you might want to do a Lounge Search in Access and also in VB/VBA/.Net.
    Charlotte

  10. #10
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preventing CLosure (Access 2000 SR1)

    Thanks - I'll have a look around

  11. #11
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preventing CLosure (Access 2000 SR1)

    James,
    Here is a little DB I put together that will do what you want plus it disables the Shift bypass
    Scott
    Attached Files Attached Files

  12. #12
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preventing CLosure (Access 2000 SR1)

    Thanks - will have a look at it and see how it goes....

  13. #13
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preventing CLosure (Access 2000 SR1)

    At first glance over the code - very impressive! Expecially for the amount of code there is..

    It take myself and the 2 other guys in the department I'm in some time to figure this all out and sketch out your design.

    Just wondering, do you have your design for this layed out in a document or on paper somewhere.
    And would I be allowed to implement your design in the program that I am writing? (I am working for a non-profit organisation at the moment).

  14. #14
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preventing CLosure (Access 2000 SR1)

    James,
    Feel free to use it. I can't take full credit for the code. I found some of it searching on the web and modified it and added code to meet my needs. Just make sure you set the correct startup form name in the code.
    Scott
    <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

  15. #15
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Preventing CLosure (Access 2000 SR1)

    Thanks very much!

    James

Posting Permissions

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