EPUB | CHM | PDF

TDataSet.Events.OnCalcFields

Top Previous Next

Occurs when an application recalculates calculated fields.

Syntax:

property OnCalcFields: TDataSetNotifyEvent;

Description:

Write an OnCalcFields event handler to take specific action when an application recalculates calculated fields. A calculated field is one that derives its value from the values in one or more fields in the dataset, sometimes with additional processing.

When the AutoCalcFields property is True, OnCalcFields is triggered when:

A dataset is opened.

A dataset is put into dsEdit state.

Focus moves from one visual control to another, or from one column to another is a data-aware grid control and modifications were made to the record.

A record is retrieved from a database.

note When the AutoCalcFields property is True, an OnCalcFields event handler should not modify the dataset (or a linked dataset if it is part of a master-detail relationship), because such modifications retrigger the OnCalcField event, leading to recursion.

If an application permits users to change data, OnCalcFields is frequently triggered. To reduce the frequency with which OnCalcFields occurs, set AutoCalcFields to False. When AutoCalcFields is False, OnCalcFields is not called when changes are made to individual fields within a record.

warning When the dataset is the master table of a master-detail relationship, OnCalcFields occurs before detail sets have been synchronized with the master table.