Top Previous Next

Occurs each time a different record in the dataset becomes the active record and filtering is enabled.


type TFilterRecordEvent = procedure(DataSet: TDataSet;
                                 var Accept: Boolean) of object;
property OnFilterRecord: TFilterRecordEvent;


Write an OnFilterRecord event handler to specify for each record in a dataset whether it should be visible to the application. To indicate that a record passes the filter condition, an OnFilterRecord event handler must set the Accept parameter to True. To exclude a record, set the Accept parameter to False.

Filtering is enabled if the Filtered property is True. When an application is processing a filter, the State property for the dataset is dsFilter.

Use an OnFilterRecord event handler to filter records using a criterion that can't be implemented using the Filter property.

Be sure that the interactions between the Filter property and the OnFilterRecord event handler do not result in an empty filter set when they are used simultaneously in an application.


The following example shows how to use a field comparison when filtering records on a local table, by using the OnFilterRecord event.

procedure TForm1.PSQLTable1FilterRecord(DataSet: TDataSet;
                                     var Accept: Boolean);
  Accept := DataSet['DateOfPayment'] > DataSet['DateOfPurchase'] + 30;