Create a table with ADOX.Table and ADO data type : ADO Data Type « Access « VBA / Excel / Access / Word






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

 








Related examples in the same category

1.ADO Equivalents to Access Data Types
2.adInteger and adWChar