Create Table Example

The following example creates a new Table object and appends it to the Tables collection of the current database.

Note   A reference to "Microsoft ADO ext. 2.1 for DDL and Security" must be set to use this example.

Sub NewTable()
    Dim cat As New ADOX.Catalog, tbl As New ADOX.Table
    
    ' Return reference to current database.
    Set cat.ActiveConnection = CurrentProject.connection
    
    tbl.Name = "Contacts"

    ' Define column to table.
    tbl.Columns.Append "ContactName", adVarWChar, 40

    ' Append Table object to Tables collection of Catalog.
    cat.Tables.Append tbl
    cat.Tables.Refresh
    Set cat = Nothing
End Sub