Article ID: 108146
Article Last Modified on 1/8/2003
Sub Form_Load ()
Const DB_LANG_GENERAL = ";LANGID=0x0809;CP=1252;COUNTRY=0"
Dim db As Database
Dim tdEmployee As New TableDef
Dim tdStore As New TableDef
Dim fEmp_ID As New Field
Dim fEmp_FirstName As New Field
Dim fEmp_LastName As New Field
Dim fEmp_Address As New Field
Dim fStore_ID As New Field
Dim fStore_Location As New Field
Dim indxEmployee As New Index
Dim indxStore As New Index
Set db = CreateDatabase("COMPANY.MDB", DB_LANG_GENERAL)
tdEmployee.Name = "Employee"
tdStore.Name = "Store"
'Define all Employee fields
fEmp_ID.Name = "Emp_ID"
fEmp_ID.Type = 4 'Long integer
fEmp_FirstName.Name = "Emp_FirstName"
fEmp_FirstName.Type = 10 'Text (32)
fEmp_FirstName.Size = 32
fEmp_LastName.Name = "Emp_LastName"
fEmp_LastName.Type = 10 'Text (32)
fEmp_LastName.Size = 32
fEmp_Address.Name = "Address"
fEmp_Address.Type = 10 'Text (256)
fEmp_Address.Size = 255
'Define all Store fields
fStore_ID.Name = "Store_ID"
fStore_ID.Type = 4 'Long integer
fStore_Location.Name = "Store_Location"
fStore_Location.Type = 10 'Text (256)
fStore_Location.Size = 255
'Add employee fields to Fields collection
tdEmployee.Fields.Append fEmp_ID
tdEmployee.Fields.Append fEmp_FirstName
tdEmployee.Fields.Append fEmp_LastName
tdEmployee.Fields.Append fEmp_Address
'Add store fields to Fields collection
tdStore.Fields.Append fStore_ID
tdStore.Fields.Append fStore_Location
'Define employee table index
indxEmployee.Name = "INDEX_EMPLOYEE"
indxEmployee.Fields = "Emp_ID"
indxEmployee.Unique = True
indxEmployee.Primary = True
'Define store table index
indxStore.Name = "INDEX_STORE"
indxStore.Fields = "Store_ID"
indxStore.Unique = True
indxStore.Primary = True
'Append the employee and store indexes
'to the respective Indexes collection
tdEmployee.Indexes.Append indxEmployee
tdStore.Indexes.Append indxStore
'Append employee and store TableDefs
'to TableDefs collection
db.TableDefs.Append tdEmployee
db.TableDefs.Append tdStore
End Sub
Additional query words: 3.00
Keywords: KB108146