Setting a Default Value for a Field

From RAD Studio
Jump to: navigation, search

Go Up to Working with Field Components Index

You can specify how a default value for a field in a client dataset or a BDE-enabled dataset should be calculated at run time using the DefaultExpression property. DefaultExpression can be any valid SQL value expression that does not refer to field values. If the expression contains literals other than numeric values, they must appear in quotes. For example, a default value of noon for a time field would be

'12:00 00'

including the single quotes around the literal value.

Note: If the underlying database table defines a default value for the field, the default you specify in DefaultExpression takes precedence. That is because DefaultExpression is applied when the dataset posts the record containing the field, before the edited record is applied to the database server.

See Also