Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.Close for entire Access Program 2

Status
Not open for further replies.

attrofy

IS-IT--Management
Jan 10, 2002
694
US
Hello,

This should be a simple one...

On one of my switchboard menu's I have an exit button. With the Exit Application command, it closes my form but leaves Access open. For our "computer-illiterate" users this is posing some difficulties.

Anyway to change the exit button to "Run Code" and do a DoCmd.Close (or as in Word - Documents.Close (these give errors)) and shut down all open Access Windows and the entire database, and the enitre Access Program? It has to be something simple...?

TIA,
Russell
 
From Access 2000 help:

Quit Method (Application Object)


The Quit method quits Microsoft Access. You can select one of several options for saving a database object before quitting.

Syntax

Application.Quit [option]

The Quit method has the following argument.

Argument Description
option An intrinsic constant that specifies what happens to unsaved objects when you quit Microsoft Access. This argument can be any of the following constants.
Constant Description

acSaveYes (Default) Saves all objects without displaying a dialog box.
acPrompt Displays a dialog box that asks whether you want to save any database objects that have been changed but not saved.
acExit Quits Microsoft Access without saving any objects.


Remarks

The Quit method has the same effect as clicking Exit on the File menu. You can create a custom menu command or a command button on a form with a procedure that includes the Quit method. For example, you can place a Quit button on a form and include a procedure in the button's Click event that uses the Quit method with the option argument set to acSaveYes.

Example:

Quit Method (Application Object) Example

The following example shows the Click event procedure for a command button named AppExit. After clicking the AppExit button, a dialog box prompts the user to save changes, and the procedure quits Microsoft Access.

Private Sub AppExit_Click()
Application.Quit acPrompt
End Sub
Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
THoey,
Thanks for the info, I found the Quit Application from the DoCmd help files, but I am still getting an error. It must be a synatx issue.

In my Switchboard button I have:

Text: Exit
Command: Run Code
Function Name: Application.Quit acSaveYes

and I am getting the error message "There was an error executing the command"

What am I doing wrong?

Thanks for the help.
Russell
 
I pasted in the snippette example into the document with the modification of acSaveYes and pasted in AppExit_Click()into the Function Name box - still no joy in mudville. Must be a syntax issue.
 
I am still getting the same error. Is it possible I have a setting wrong or something turned off (or on) or some module not installed???
 
Paste this into a module:

Public Function App_Quit()
DoCmd.Quit
End Function



then in the Switchboard Manager, set the Exit button (or Close if that's what you've named it) to:

Command - Run Code
Function Name - App_Quit
 
That was the ticket Rick - it needed to be a function instead of an event. Stars for all.
 
Glad you got is solved while I was away... Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top