Append Method Example (MDB)

The following example defines a new Field object and appends it to the Fields collection of a TableDef object:

Sub NewField()
    Dim dbs As Database, tdf As TableDef, fld As Field

    ' Return reference to current database.
    Set dbs = CurrentDb
    Set tdf = dbs.TableDefs!Employees
    ' Create new field in Employees table.
    Set fld = tdf.CreateField("SocialSecurity#", dbText, 11)
    ' Append field and refresh collection.
    tdf.Fields.Append fld
    tdf.Fields.Refresh
    Set dbs = Nothing
End Sub