By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,490 Members | 1,753 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,490 IT Pros & Developers. It's quick & easy.

Exit Application from Switchboard

Catalyst159
100+
P: 111
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.
Expand|Select|Wrap|Line Numbers
  1.  Case conCmdExitApplication
  2.             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.
Dec 16 '11 #1

✓ answered by NeoPa

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 :

Expand|Select|Wrap|Line Numbers
  1. 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.

Share this Question
Share on Google+
6 Replies


dsatino
100+
P: 393
Just put this in the onclick event:

docmd.quit
Dec 16 '11 #2

Catalyst159
100+
P: 111
How can I tell which button it is if I used the switchboard manager to create the switchboard.
Dec 16 '11 #3

Catalyst159
100+
P: 111
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:
Expand|Select|Wrap|Line Numbers
  1. If MsgBox("Are you sure that you want to quit this database?", vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
  2. DoCmd.Quit
  3. End If
Dec 16 '11 #4

NeoPa
Expert Mod 15k+
P: 31,709
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.
Dec 16 '11 #5

Catalyst159
100+
P: 111
How can I make sure that the objects are saved automatically?

Would this work:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Option3_Click()
  2. If MsgBox("Are you sure that you want to quit this database?", vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
  3. Application.Quit (acQuitPrompt)
  4. End If
  5. End Sub
Or will you get a prompt asking to save when using (acQuitPrompt).

Or would Private this be better:
Expand|Select|Wrap|Line Numbers
  1. Sub Option3_Click()
  2. If MsgBox("Are you sure that you want to quit this database?", vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
  3. Application.Quit (acQuitSaveAll)
  4. End If
  5. End Sub
Dec 16 '11 #6

NeoPa
Expert Mod 15k+
P: 31,709
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 :

Expand|Select|Wrap|Line Numbers
  1. 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.
Dec 16 '11 #7

Post your reply

Sign in to post your reply or Sign up for a free account.