Name Property Example (MDB)

The following example creates two new TableDef objects and names them. The name of the first TableDef object is included as an argument to the CreateTableDef method. The name of the second TableDef object is set by using the Name property, after the TableDef object has been created.

Note that you must define fields in the table before the TableDef object can be appended to the TableDefs collection.

Sub NameNewTables()
    Dim dbs As Database
    Dim tdfDefinitions As TableDef, tdfSynonyms As TableDef

    ' Return reference to current database.
    Set dbs = CurrentDb
    ' Create new TableDef object.
    Set tdfDefinitions = dbs.CreateTableDef("Definitions")
    ' Create second TableDef object.
    Set tdfSynonyms = dbs.CreateTableDef("")
    ' Set Name property for second TableDef object.
    tdfSynonyms.Name = "Synonyms"
    .                            ' Create fields.
    .
    .
    dbs.TableDefs.Append tdfDefinitions
    dbs.TableDefs.Append tdfSynonyms
    Set dbs = Nothing
End Sub