DefaultValue Property

See Also        Applies To

Sets or returns the default value of a CdbField object. For a CdbField object not yet appended to the Fields collection, this property is read/write (Microsoft Jet workspaces only).

Syntax

VOIDSetDefaultValue(LPCTSTR pstr );

CStringGetDefaultValue(VOID);

Parameters

Type Argument Description
LPCTSTR pstr A pointer to a string that contains a maximum of 255 characters. It can be either text or an expression. If the property setting is an expression, it can't contain user-defined functions, Microsoft Jet database engine SQL aggregate functions, or references to queries, forms, or other CdbField objects.

Remarks

The availability of the DefaultValue property depends on the object that contains the Fields collection, as shown in the following table.

If the Fields collection belongs to a Then DefaultValue is
CdbIndex object Not supported
CdbQueryDef object Read-only
CdbRecordset object Read-only
CdbRelation object Not supported
CdbTableDef object Read/write

When a new record is created, the DefaultValue property setting is automatically entered as the value for the field. You can change the field value by setting its Value property.

Note You can also set the DefaultValue property of a CdbField object on a CdbTableDef object to a special value called "GenUniqueID( )". This causes a random number to be assigned to this field whenever a new record is added or created, thereby giving each record a unique identifier. The field's Type property must be Long.

The DefaultValue property doesn't apply to AutoNumber and Long Binary fields.