Delete Method Example (MDB)

The following example creates a field in a table and then deletes the field:

Sub DeleteField()
    Dim dbs As Database, tdf As TableDef
    Dim fldInitial As Field
    
    ' Return reference to current database.
    Set dbs = CurrentDb
    Set tdf = dbs.TableDefs!Employees
    ' Create new Field object.
    Set fldInitial = tdf.CreateField("MiddleInitial", dbText, 2)
    ' Append new Field object.
    tdf.Fields.Append fldInitial
    ' Refresh Fields collection.
    tdf.Fields.Refresh
    ' Delete new Field object.
    tdf.Fields.Delete fldInitial.Name
    tdf.Fields.Refresh
    Set dbs = Nothing
End Sub