adInteger and adWChar : ADO Data Type « Access « VBA / Excel / Access / Word






adInteger and adWChar

 
Sub CreateTable()
    Dim tdf As ADOX.Table
    Dim idx As ADOX.Index
    Dim cat As ADOX.Catalog
    Set cat = New ADOX.Catalog
    cat.ActiveConnection = CurrentProject.Connection
    Set tdf = New ADOX.Table
    With tdf
        .Name = "Foods"
        Set .ParentCatalog = cat
        .Columns.Append "ID", adInteger
        .Columns("ID").Properties("AutoIncrement") = True
        .Columns.Append "Description", adWChar
        .Columns.Append "Calories", adInteger
    End With
    cat.Tables.Append tdf
    Set idx = New ADOX.Index
    With idx
        .Name = "PrimaryKey"
        .Columns.Append "ID"
        .PrimaryKey = True
        .Unique = True
    End With
    tdf.Indexes.Append idx
    Set idx = Nothing
    Set cat = Nothing
End Sub

 








Related examples in the same category

1.ADO Equivalents to Access Data Types
2.Create a table with ADOX.Table and ADO data type