Application Object

Access Developer Reference

The Application object refers to the active Microsoft Office Access application.

Remarks

The Application object contains all Access objects and collections.

You can use the Application object to apply methods or property settings to the entire Access application. For example, you can use the SetOption method of the Application object to set database options from Visual Basic. The following example shows how you can set the Display Status Bar check box on the Current Database tab of the Access Options dialog box.

Visual Basic for Applications
  Application.SetOption "Show Status Bar", True

Access is a COM component that supports Automation, formerly called OLE Automation. You can manipulate Access objects from another application that also supports Automation. To do this, you use the Application object.

For example, Microsoft Visual Basic is a COM component. You can open anAccess database from Visual Basic and work with its objects. From Visual Basic, first create a reference to the Microsoft Office Access 2007 object library. Then create a new instance of the Application class and point an object variable to it, as in the following example:

Visual Basic for Applications
  Dim appAccess As New Access.Application

From applications that do not support the New keyword, you can create a new instance of the Application class by using the CreateObject function:

Visual Basic for Applications
  Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")

After you create a new instance of the Application class, you can open a database or create a new database, by using either the OpenCurrentDatabase method or the NewCurrentDatabase method. You can then set the properties of the Application object and call its methods. When you return a reference to the CommandBars object by using the CommandBars property of the Application object, you can access all 2007 Microsoft Office system command bar objects and collections by using this reference.

You can also manipulate other Access objects through the Application object. For example, by using the OpenForm method of the Access DoCmd object, you can open an Access form from Microsoft Office Excel:

Visual Basic for Applications
  appAccess.DoCmd.OpenForm "Orders"

For more information about creating a reference and controlling objects by using Automation, see the documentation for the application that is acting as the COM component.

See Also