DefaultValue Property Example (MDB)
The following example creates a new Field object and sets its DefaultValue property. The procedure then appends the new object to the Fields collection of the Employees table in the TableDefs collection of the database.
Sub NewField()
Dim dbs As Database, tdf As TableDef
Dim fld As Field
' Return reference to current database.
Set dbs = CurrentDb
' Return reference to Employees table.
Set tdf = dbs.TableDefs!Employees
' Create Field object.
Set fld = tdf.CreateField("DaysOfVacation", dbText, 20)
' Set field properties.
fld.DefaultValue = "10"
' Append fld to Fields collection.
tdf.Fields.Append fld
Set dbs = Nothing
End Sub