SelectObject


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

  • 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.




Access VBA Programming
Microsoft Access VBA Programming for the Absolute Beginner
ISBN: 1598633937
EAN: 2147483647
Year: 2006
Pages: 214
Authors: Michael Vine

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net