• Preventing CLosure (Access 2000 SR1)

    Author
    Topic
    #369014

    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

    Viewing 1 reply thread
    Author
    Replies
    • #579860

      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.

      • #579863

        And what is the code to actually cancel the event?

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

        James

        • #579868

          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

          • #579869

            http://www.mvps.org/access/general/gen0005.htm%5B/url%5D

            Edited by Charlotte to activate link

            • #580099

              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

            • #580133

              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.

            • #580139

              Thanks – I’ll have a look around

          • #580098

            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

            • #580132

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

    • #580181

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

      • #580380

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

      • #580382

        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).

        • #580470

          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
          cool

    Viewing 1 reply thread
    Reply To: Preventing CLosure (Access 2000 SR1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: