>
Part | Description |
object | An object expression that evaluates to an object in the Applies To list. |
databasetype | A string expression that specifies a database type. For Microsoft Jet databases, exclude this argument; if you specify parameters, use a semicolon (;) as a placeholder. The data type is String. |
parameters | A string expression that specifies additional parameters to pass to ODBC or installable ISAM drivers. Use semicolons to separate parameters. The data type is String. |
Database type | Specifier | Path |
Database using the Jet database engine | "[database];" | "drive:\path\filename.mdb" |
dBASE III® | "dBASE III;" | "drive:\path" |
dBASE IV® | "dBASE IV;" | "drive:\path" |
dBASE 5 | "dBASE 5;" | "drive:\path" |
Paradox 3.x | "Paradox 3.x;" | "drive:\path" |
Paradox 4.x | "Paradox 4.x;" | "drive:\path" |
Paradox 5.x | "Paradox 5.x;" | "drive:\path" |
Btrieve | "Btrieve;" | "drive:\path\filename.ddf" |
FoxPro® 2.0 | "FoxPro 2.0;" | "drive:\path" |
FoxPro 2.5 | "FoxPro 2.5;" | "drive:\path" |
FoxPro 2.6 | "FoxPro 2.6;" | "drive:\path" |
Excel 3.0 | "Excel 3.0;" | "drive:\path\filename.xls" |
Excel 4.0 | "Excel 4.0;" | "drive:\path\filename.xls" |
Excel 5.0 | "Excel 5.0;" | "drive:\path\filename.xls" |
Excel 7.0 | "Excel 7.0;" | "drive:\path\filename.xls" |
Text | "Text;" | "drive:\path" |
ODBC | "ODBC; DATABASE=defaultdatabase; UID=user; PWD=password; DSN=datasourcename LOGINTIMEOUT=seconds" (This may not be a complete connection string for all servers; it's just an example.) | None |
Function ConnectSource () As Integer Dim dbsLocal As Database, tdfPDXAuthor As TableDef Set dbsLocal = DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb") Set tdfPDXAuthor = dbsLocal.CreateTableDef("PDXAuthor") ' Attach Paradox table Author in database C:\PDX\PUBLISH. tdfPDXAuthor.Connect = "Paradox 4.x;DATABASE=C:\PDX\PUBLISH" tdfPDXAuthor.SourceTableName = "Author" dbsLocal.TableDefs.Append tdfPDXAuthor ' Attach table. ConnectSource = True End FunctionExample (Microsoft Access) The following example creates a TableDef object in the specified database. The procedure then sets its Connect, Name, and SourceTableName properties and appends the object to the TableDefs collection.
Sub ConnectSource() Dim dbs As Database, tdf As TableDef ' Return Database variable that points to current database. Set dbs = CurrentDb Set tdf = dbs.CreateTableDef("PDXAuthor") ' Attach Paradox table Author in database C:\PDX\Publish. tdf.Connect = "Paradox 4.x;DATABASE=C:\PDX\Publish" tdf.SourceTableName = "Author" dbs.TableDefs.Append tdf End SubExample (Microsoft Excel) This example attaches the table PRODUCT.DBF (a dBASE IV table located in the \Program Files\Common Files\Microsoft Shared\MSquery folder) to the NWINDEX.MDB database. (On Windows NT, PRODUCT.DBF is located in the \WINDOWS\MSAPPS\MSQUERY folder.) To create the NWINDEX.MDB database, run the Microsoft Excel example for the CreateDatabase method.
Const sourceDir = "C:\Program Files\Common Files\Microsoft Shared\" Dim nWindEx As Database, tDef As TableDef Dim dataSource As String dataSource = "dbase IV;DATABASE=" & sourceDir & "MSquery" Set nWindEx = Workspaces(0).OpenDatabase(Application.Path _ & "\NWINDEX.MDB") Set tDef = nWindEx.CreateTableDef("Product") tDef.Connect = dataSource tDef.SourceTableName = "Product" nWindEx.TableDefs.Append tDef nWindEx.Close