CreateDatabase, CreateTableDef, Append Methods Example
This example creates a new database, Nwindex.mdb. The example attaches three dBASE IV tables from the C:\Program Files\Microsoft Office\Office folder to the database.
Dim nWindEx As Database, customerTable As TableDef
Dim orderTable As TableDef, employeeTable As TableDef
Dim dataSource As String
dataSource = "dBASE IV;" & _
"DATABASE=C:\Program Files\Microsoft Office\Office"
appPath = Application.DefaultFilePath
Set nWindEx = Workspaces(0) _
.CreateDatabase(Application.DefaultFilePath _
& "\NWINDEX.MDB", dbLangGeneral)
' add Customer table
Set customerTable = nWindEx.CreateTableDef("Customer")
customerTable.Connect = dataSource
customerTable.SourceTableName = "Customer"
nWindEx.TableDefs.Append customerTable
' add Orders table
Set orderTable = nWindEx.CreateTableDef("Orders")
orderTable.Connect = dataSource
orderTable.SourceTableName = "Orders"
nWindEx.TableDefs.Append orderTable
' add Employee table
Set employeeTable = nWindEx.CreateTableDef("Employee")
employeeTable.Connect = dataSource
employeeTable.SourceTableName = "Employee"
nWindEx.TableDefs.Append employeeTable
MsgBox "The database " & nWindEx.Name & " has been created."
nWindEx.Close