Selects a database object in order to perform some operation on it.
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.
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
SelectObject works with any object that can receive the focus. It gives the selected database object the focus and, in the case of a hidden form, sets its Visible property to True.
SelectObject can be used to select a database object before calling a method that only applies to the active object.
The documentation lists acDefault as a possible value for ObjectType, although in fact it generates a syntax error.