Mega Code Archive

 
Categories / VisualBasic Script / Access
 

Create a table with ADOX Table and ADO data type

Sub makeTable()    Dim currCat As New ADOX.Catalog    Dim newTable As New ADOX.Table    Dim newKey As New ADOX.Key        currCat.ActiveConnection = CurrentProject.Connection        With newTable       .Name = "tblTestTable"       .Columns.Append "custNumber", adInteger       .Columns("custNumber").ParentCatalog = currCat       .Columns("custNumber").Properties("AutoIncrement") = True              newKey.Name = "PrimaryKey"       newKey.Columns.Append "custNumber"       .Keys.Append newKey, adKeyPrimary              .Columns.Append "custFirstName", adWChar       .Columns.Append "custLastName", adWChar      End With            currCat.Tables.Append newTable            Set currCat = Nothing End Sub