Exit Application from Switchboard

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Catalyst159
    New Member
    • Sep 2007
    • 111

    Exit Application from Switchboard

    I am using a Switchboard that contains an 'Exit Application' button. The code that the Switchboard uses for exiting the application is:
    ' Exit the application.
    Code:
     Case conCmdExitApplication
                CloseCurrentDatabase
    This does not actually Exit the Application as I would like. It only closes the db. I would like to close the db and exit Microsoft Access completely. Any help, tips, ideas or input is welcome. I appreciate any assistance. Thanks in advance.
  • dsatino
    Contributor
    • May 2010
    • 393

    #2
    Just put this in the onclick event:

    docmd.quit

    Comment

    • Catalyst159
      New Member
      • Sep 2007
      • 111

      #3
      How can I tell which button it is if I used the switchboard manager to create the switchboard.

      Comment

      • Catalyst159
        New Member
        • Sep 2007
        • 111

        #4
        Looks like the button is referred to as "Option 3". I am using the following in the 'OnClick' event procedure and it seems to work ok:
        Code:
        If MsgBox("Are you sure that you want to quit this database?", vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
        DoCmd.Quit
        End If

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32656

          #5
          DoCmd.Quit is provided for backwards compatibility. The recommended approach is to use the Application's Quit(Option) method, where you can choose whether or not objects are saved automatically or the operator is prompted.

          Comment

          • Catalyst159
            New Member
            • Sep 2007
            • 111

            #6
            How can I make sure that the objects are saved automatically?

            Would this work:
            Code:
            Private Sub Option3_Click()
            If MsgBox("Are you sure that you want to quit this database?", vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
            Application.Quit (acQuitPrompt)
            End If
            End Sub
            Or will you get a prompt asking to save when using (acQuitPrompt).

            Or would Private this be better:
            Code:
            Sub Option3_Click()
            If MsgBox("Are you sure that you want to quit this database?", vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
            Application.Quit (acQuitSaveAll)
            End If
            End Sub
            Last edited by NeoPa; Dec 16 '11, 05:46 PM.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32656

              #7
              You were so quick you missed me updating the post.

              Actually, a very quick check (even typing the command prompts you with the available options) would have helped you realise that line #3 should be :

              Code:
              Call Quit(acQuitSaveAll)
              PS. It seems you've realised this for yourself now. It is generally a good idea to have a little bit of a think and a check before firing off posts. Otherwise it results in a rambling mess. I'll tidy this up where I can.

              Comment

              Working...