Microsoft KB Archive/210518

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

Article ID: 210518

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition
 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210518



Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



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



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:  Start Microsoft Access and open any database. Start Microsoft Excel, point to Macro on the Tools menu, and then click Visual Basic Editor. On the Insert menu, click Module.  Type the following Sub procedure: Sub OleAccess Dim appAccess as Object Set appAccess = GetObject(, "Access.Application") appAccess.Quit acSave End Sub  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.

<div class="references_section">