[SOLVED] onDataChange Event when Datasource.dataset reloads lazarus / 16-Databases ---------------------------------------------------------------------- Lostisimus · 2021-02-07 22:50 I hope you can make sense of my attempt to verbalize my problem, sorry for that. I Have two SqlQuery dataset components set up as Master/Detail in datamodule (connected with a DataSource). Using a dbGrid for detail data, I can confirm that the setup is correct, the data changes when i scroll the master. On a form I am trying to use the onDataChange eventhandler to do stuf after the detail SqlQuery is reloaded, I think this is also what is causing the problem (the DataSet reloading in stead of a "regular" dataChange). When in the onDataChange eventhandler i try to access the detail SqlQuery dataset itself I get access violations, because it (the detail SqlQuery dataset) does not seem to be ready (i guess). I also tried to use the onDataChange event using a DataSource on the master SqlQuery dataset, with same result. Is there a way to catch the right moment after the detail SqlQuery dataset is reloaded, to program stuf, for instance load non data aware components? Thanks in advance. ---------------------------------------------------------------------- Lostisimus · 2021-02-08 13:21 Problem solved, i was really goofing up here. If you read carefully i am creating an endless loop in the onDataChange. This was hidden by trying to address a non assigned dataModule variable  . I tryed to remove this post but for some reason i am not able to. It is now working by using onStateChange in stead of onDataChange event of the DataSource. 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 procedure TfrmReadForm.dsVertalingenStateChange(Sender: TObject);begin  with MainDataMod do  begin    try      /// This check is important, because also goes through state inactive      if SQLQryVertalingen.State in [dsBrowse] then      begin        SQLQryVertalingen.First;        While not SQLQryVertalingen.Eof do        begin          {Bla bla}        SQLQryVertalingen.Next;        end;      end;    finally    end;  end;end;