Subject IB_Query remains in EditMode after Posting
Author andygarneruk
I am attempting a secondary update to a dataset in its AfterPost
event. However the dataset then remains in dssEdit mode rather than
returning to dssBrowse once the AfterPost completes.

This seems to be because TIB_Dataset.SysPost does not action my
secondary Post due to 'IsPosting' (1) being True.

Further investigation suggests that 'IsPosting' returns true
when 'FIsPostingLevel' is greater than zero, which seems to the case
at the time the AfterPost event is called (2) - the decrement
of 'FPostingLevel' does not occur until later (3).

So is it posssible to re-update a dataset in its AfterPost event, and
if not are there any suggested workrounds please?

(W2K, IBO 4.2Ie, default transaction).

Thanks, Andy Garner.

procedure TIB_Dataset.SysPost( CancelUnmodified, IsRetaining:
boolean );
begin
if State = dssSearch then
SysPostSearch( true )
else
if NeedToPost and
( not IsPosting <= (1)
( IsRetaining and not IsPostRetaining )) then
begin
Inc( FIsPostingLevel );
if IsRetaining then
Inc( FIsPostRetainingLevel );
try
if State in [dssEdit, dssInsert] then
ProcessLinkEvent( setFieldsUpdateData, 0 );
try
DisableControls;
if State in [dssEdit, dssInsert] then
SysMasterDataUpdate( nil );
if (( CancelUnmodified ) or
( IB_Connection.ConnectionStatus in [ csDisconnectPending,
csDropPending ] ))
and
not IsRetaining and
not Modified and
( State in [dssEdit, dssInsert] ) then
SysCancel
else
begin
SysBeforePost;
if ( State in [dssEdit, dssInsert] ) and CheckRequired then
CheckRequiredFields;
if not IsRetaining then
ProcessLinkEvent( setCheckBrowseMode, 0 );
FPostedState := State;
SysExecPost( CancelUnmodified and not IsRetaining );
try
if not IsRetaining then
SysUpdateState;
SysUpdateKeyLinksData;
finally
FHasPostRetained := IsRetaining;
if IsRetaining then
Fields.SetRowState( rsModified );
if Fields.PSQLDA.SQLn > Fields.PSQLDA.SQLd then
CalculateFields;
if not FCachedUpdates then
case FPostedState of
dssInsert: Include( FDatasetFlags,
dsfInsertWasPosted );
dssEdit: Include( FDatasetFlags, dsfEditWasPosted );
dssDelete: Include( FDatasetFlags,
dsfDeleteWasPosted );
end;
SysAfterPost; <= (2)
end;
end;
finally
EnableControls;
end;
finally
Dec( FIsPostingLevel ); <= (3)
if IsRetaining then
Dec( FIsPostRetainingLevel );
end;
end;
end;