Post in master calls AfterPost in detail lazarus / 16-Databases ---------------------------------------------------------------------- fpcoder · 2017-03-13 10:26 qryDetail has qryMaster as DataSource. Is it expected behaviour that qryMaster.Post triggers AfterPost in qryDetail? ---------------------------------------------------------------------- Thaddy · 2017-03-13 10:35 Why would you expect otherwise? You may have to update the detail to reflect the current status. ---------------------------------------------------------------------- fpcoder · 2017-03-13 11:22 Still learning about database events. Why is qryDetail.AfterPost triggered by qryMaster? I have a settings dialog where fields in qryMaster are edited and posted first, and if qryDetail is modified too it is also posted. But it never gets posted since qryMaster triggered qryDetail's afterpost and qryDetail.Modified is no longer true: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TfrmDataset.SaveDataset: Boolean;begin  Result:=False;  if ValidateInput then  try    try      DM.qryDataset.Post;      DM.qryDataset.ApplyUpdates;       if DM.qryLinks.Modified then      begin        DM.qryLinks.FieldByName('dataset_id').AsInteger:=        DM.qryDataset.FieldByName('dataset_id').AsInteger;         DM.qryLinks.Post;        DM.qryLinks.ApplyUpdates;      end;      DM.TX.CommitRetaining;      Result:=True;    except      DM.TX.RollbackRetaining;    end;  finally    DM.qryLinks.Close;    DM.qryDataset.Close;  end;end; I supply the dataset_id manually since UpdateSQL/InsertSQL etc doesn't make use of parameters. ---------------------------------------------------------------------- goodname · 2017-03-13 17:09 Not really what you were asking but try not to use the CommitRetaining or RollbackRetaining in transactions. It leads to long running idle transactions which is generally considered to be a program bug. Instead use TSQLQuery option sqlAutoCommit or sqlKeepOpenOnCommit with Commit. ---------------------------------------------------------------------- fpcoder · 2017-03-15 19:19 @goodname Good to know, I changed to sqlKeepOpenOnCommit and it seems to work fine. When it was clear that Post of detail is triggered by Post of master, I assigned the dataset_id value in detail's BeforePost and called ApplyUpdates in detail's AfterPost.