See Also Example
Description
Visual Basic provides a number of ways to access data from external databases For more information on accessing external tables, see the EXTERNAL.TXT readme file.
Professional Edition
In the Professional Edition, you can also use the OpenDatabase function to access external tables. Set the connect part to the appropriate database type and any needed connection parameters, and set the DatabaseName argument to either "ODBC;" for ODBC databases, or to the directory or file name of the external database.
In addition, you can attach an external table to an existing Visual Basic database. This creates a link to an external table in your Visual Basic database. You cannot open a Table object with the OpenTable method based on attached tables. You can write code to create a database and attach external tables.
To attach tables to an existing Visual Basic database
1. Create a variable for the Database object you are going to modify:
Dim Db As Database
2. Use OpenDatabase to open the existing database:
Set Db = OpenDatabase("C:\VB\BIBLIO.MDB")
3. Create a new TableDef object for the external table, set the TableDef properties to link to the attached table, and add it to the TableDefs collection with the Append method.
a. Create a new TableDef object, and set the following TableDef properties:
Namethe name to be used in Visual Basic.
SourceTableNamethe original name of the table or file name.
Connectthe database type and other parameters.
b. Repeat the preceding step for each external Table, then add the TableDef object to the Database with the Append method. This is the step that actually creates the object links in the database file.