dataset editing/inserting & filter
Posted: Wed 01 Jun 2016 12:54
Hi,
I'm having following problem: i have a filtered tmsquery (filter = 'a = 5'), do an append, set a to 6 and post. the record immediately after post disappers. Even in afterpost is an other record active. This makes big trouble, if the code in afterpost event somehow analyzes the currently posted data (as it analyzes an other record).
Is there some nice way to "correct" this? Or, at least, to disallow such post, if the new record won't meet the filter criteria? I tried anything like subclassing tmsquery and writing code like
byt currentitem is nil dataset in dsinsert state... also OmitRecord(activebuffer) did not work... Some other way?
Thanks, Ludek.
I'm having following problem: i have a filtered tmsquery (filter = 'a = 5'), do an append, set a to 6 and post. the record immediately after post disappers. Even in afterpost is an other record active. This makes big trouble, if the code in afterpost event somehow analyzes the currently posted data (as it analyzes an other record).
Is there some nice way to "correct" this? Or, at least, to disallow such post, if the new record won't meet the filter criteria? I tried anything like subclassing tmsquery and writing code like
Code: Select all
procedure TMyMSQuery.InternalPost;
begin
if (data as TMemData).OmitRecord((data as TMemData).GetCurrentItem) then
raise Exception.Create('Saved record would be filtered out. Save aborted.');
inherited;
end;
Thanks, Ludek.