>
AllowZeroLength Property
Applies To
Field Object.
Description
Sets or returns a value that indicates whether a zero-length string ("") is a valid setting for the Value property of a Field object with a Text or Memo data type. For an object not yet appended to the Fields collection, this property is read/write.
Settings and Return Values
The setting or return value is a Boolean expression that indicates if a value is valid. The data type is Boolean. It returns True (-1) if a zero-length string is a valid value.
Remarks
For a Field object, use of the AllowZeroLength property depends on the object that contains the Fields collection that the Field object is appended to, as the following table shows.
| Object appended to | Usage |
|
| Index | Not supported |
| QueryDef | Read-only |
| Recordset | Read-only |
| Relation | Not supported |
| TableDef | Read/write |
You can set this property to False (0) to make sure you can't use a zero-length string to set the Value property of a Field object.
You can use this property along with the Required, ValidateOnSet, or ValidationRule property to determine the validity of a value in a field.
See Also
QueryDef Object, Required Property, TableDef Object, ValidateOnSet Property, ValidationRule Property, ValidationText Property, Value Property.
Example (Microsoft Access)
The following example creates a new Field object and sets its AllowZeroLength property to True.
Sub ZeroLengthField()
Dim dbs As Database, tdf As TableDef, fld As Field
' Return Database variable that points to current database.
Set dbs = CurrentDb
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
End Sub