Creating a Link to an External Table
The following procedure outlines the four steps to creating a link to an external table. (This explanation uses the CreateTableDef method and the Connect and SourceTableName properties.)
Û To create a link to an external table
-
Use the OpenDatabase method of the Workspace object to open the Microsoft Jet database that will store the linked table definition.
-
Use the CreateTableDef method of the Database object to create a table definition for the linked table. You can assign a unique, descriptive name to the TableDef object, which can be any valid Microsoft Jet table name.
-
Use the Connect and SourceTableName properties of the TableDef object to set the connection information for the linked table. This step establishes the connection and provides authentication services, such as user name and password presentation to the remote data source, if needed.
-
Use the Append method of the TableDefs collection to append the table definition for the linked table to the TableDefs collection.
After you’ve created the link, you can access the external table as you would any other table in your Microsoft Jet database. The link remains current unless you delete the link or delete or move the external table. You can update the link information to an external table that has been moved by refreshing the link.
For information about removing and refreshing links, see the “Maintaining Links” section later in this chapter.