Re: OnFilterRecord




"Rob Kennedy" <me3@xxxxxxxxxxx> wrote in message
news:3ddvmoF6p7v3qU1@xxxxxxxxxxxxxxxxx

> if ATable.Filtered then OldFilter := ATable.OnFilterRecord
> else OldFilter := nil;
> try
> ATable.OnFilterRecord := FindAddress;
> ATable.Filtered := True;
> FindAddress(ATable, OK);
> ATable.Filtered := Assigned(OldFilter);
> finally
> ATable.OnFilterRecord := OldFilter;
> end;

I suspect that there could be a problem with this when onFilterRecord
contains a method but Filtered is False. In that situation the original
onFilterRecord contents are not restored.

In the OP, Filter and FilterOptions have not been taken into account.
Another thing to consider are the side effects that are possible if/when the
record set changes. All sorts of events can be triggered when filtering is
adjusted.

ISTM that the real solution is to use a separate data set. Adjusting and
restoring just one aspect of filtering makes the code, IMO, more fragile
than needs be.


.