Accessing Automation Object Members

See Also

Microsoft® Repository contains a number of Automation objects that support multiple interfaces. With each Automation object, one interface is defined to be the default interface, and the members (the properties, methods, and collections) that are attached to that interface are accessible via the standard Visual Basic mechanisms.

When accessing members that are attached to an interface that is not the default interface for an Automation object, a different access technique must be used. An additional reference to the object must be declared that explicitly calls for the non-default interface. The non-default interface members can then be accessed via the new object reference.

The following example illustrates how to access a property that is attached to an interface that is not the default interface for an Automation object. In this example, the connection string that is used to connect to the Repository database is retrieved. Repository objects implement the IRepositoryODBC interface; this interface is not the default interface. The ConnectionString property is attached to the IRepositoryODBC interface. The ConnectionString property is the ODBC connection string that Repository uses when connecting to a database server.

Dim myRepos     As Repository
Dim nonDefIfc   As IRepositoryODBC

'  Initialize the myRepos object by opening a
'  connection to a Repository database.

Set nonDefIfc = myRepos
connect$ = nonDefIfc.ConnectionString

In this example, the nonDefIfc object does not use up additional resources; it is just an alternate view of the myRepos object.

(c) 1988-1998 Microsoft Corporation. All Rights Reserved.