AllowZeroLength Property Example (MDB)

The following example creates a new Field object and sets its AllowZeroLength property to True (–1):

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

    ' Return reference to current database.
    Set dbs = CurrentDb
    ' Return reference to Employees table.
    Set tdf = dbs.TableDefs!Employees
    ' Create new field in Employees table.
    Set fld = tdf.CreateField("SpouseName", dbText, 15)
    ' Allow zero-length strings in field.
    fld.AllowZeroLength = True
    ' Append Field object.
    tdf.fields.Append fld
    Set dbs = Nothing
End Sub