Microsoft Access VBA Programming for the Absolute Beginner

Selects a database object in order to perform some operation on it.

Syntax

DoCmd.SelectObject ObjectType[, ObjectName][, InDatabaseWindow]

with the following parameters:

ObjectType

A constant of the AcObjectType enumeration specifying the type of database object to save. Possible values are acDataAccessPage, acDiagram, acForm, acFunction (a user-defined function for SQL Server), acMacro, acModule, acQuery, acReport, acServerView, acStoredProcedure, or acTable.

ObjectName

A String specifying the name of the object to be selected.

InDatabaseWindow

If True, selects an object in the Database window. If False, the default, selects an object that’s already open.

Example

The following code selects and then copies the tblCustomer table:

Public Sub SelectAndCopyObject() Dim strTable As String DoCmd.SelectObject acTable, "tblCustomer", True DoCmd.CopyObject , "tblCustomer Original Table" End Sub

Comments

Категории