Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Use the Quit Method to Quit Access from Another Program


View products that this article applies to.

Summary

This article describes how to close Microsoft Access from a different program using Automation and the Quit method.

↑ Back to the top


More information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To close Microsoft Access from Microsoft Excel, follow these steps:
  1. Start Microsoft Access and open any database.
  2. Start Microsoft Excel, point to Macro on the Tools menu, and then click Visual Basic Editor.
  3. On the Insert menu, click Module.
  4. Type the following Sub procedure:
    Sub OleAccess()
       Dim appAccess as Object
       Set appAccess = GetObject(, "Access.Application")
       appAccess.Quit acSave
    End Sub
    					
  5. To run this code, click Run Sub/UserForm on the Run menu, or call the Sub procedure from another procedure.

    When it runs, the GetObject() function sets the appAccess variable to the first available open instance of Microsoft Access. At the end, it closes Microsoft Access with appAccess.Quit.
NOTE: If you do not have Microsoft Access running in the background when you run the procedure, you receive a run-time error. You can trap for this error by using On Error.

↑ Back to the top


References

For more information about the Quit method, click Microsoft Visual Basic Help on the Help menu, type Quit method in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

↑ Back to the top


Keywords: KB210518, kbinterop, kbhowto

↑ Back to the top

Article Info
Article ID : 210518
Revision : 4
Created on : 6/23/2005
Published on : 6/23/2005
Exists online : False
Views : 309