Writing an OnFilter Record event handler

You can write code to filter records using the OnFilterRecord events generated by the dataset for each record it retrieves. This event handler implements a test that determines if a record should be included in those that are visible to the application.

To indicate whether a record passes the filter condition, your OnFilterRecord handler sets its Accept parameter to True to include a record, or False to exclude it. For example, the following filter displays only those records with the State field set to "CA":

procedure TForm1.Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean); begin

When filtering is enabled, an OnFilterRecord event is generated for each record retrieved. The event handler tests each record, and only those that meet the filter's conditions are displayed. Because the OnFilterRecord event is generated for every record in a dataset, you should keep the event handler as tightly coded as possible to avoid adversely affecting the performance.

Displaying and editing a subset of data using filters

Was this article helpful?

0 0

Post a comment