How to detect data changed or has been Posted lazarus / 16-Databases ---------------------------------------------------------------------- CrazyRam · 2019-07-09 17:43 Hi, I'm using ZMSql for single user program and using TDBNavigator bar. Question is:  On data change the POST button is enabled. I would like to capture this so I can write a form closure procedure to warn the user that POSTed data has not been save to disk. Rgds Ram. ---------------------------------------------------------------------- dsiders · 2019-07-09 18:36 Quote from: CrazyRam on July 09, 2019, 07:43:17 pmHi, I'm using ZMSql for single user program and using TDBNavigator bar. Question is:  On data change the POST button is enabled. I would like to capture this so I can write a form closure procedure to warn the user that POSTed data has not been save to disk. Rgds Ram. The dataset should have both an UpdateStatus method and a ChangeCount property. Check those. ---------------------------------------------------------------------- wp · 2019-07-09 19:22 Quote from: CrazyRam on July 09, 2019, 07:43:17 pm[...] so I can write a form closure procedure to warn the user that POSTed data has not been save to disk. In this case the Dataset (the ZMSQLQuery) should still be in dsEdit or dsInsert state , certainly not is dsBrowse state. The state of the dataset actually is the property which is evaluated when the Post button is enabled. 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 TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);begin  if Dataset.State <> dsBrowse then begin    MessageDlg('Data not saved.', mtError, [mbOk], 0);    CanClose := false;  end;end; ---------------------------------------------------------------------- CrazyRam · 2019-07-09 21:03 Quote from: dsiders on July 09, 2019, 08:36:12 pmQuote from: CrazyRam on July 09, 2019, 07:43:17 pmHi, I'm using ZMSql for single user program and using TDBNavigator bar. Question is:  On data change the POST button is enabled. I would like to capture this so I can write a form closure procedure to warn the user that POSTed data has not been save to disk. Rgds Ram. The dataset should have both an UpdateStatus method and a ChangeCount property. Check those. I don't see those two options as part of the Dataset. Rgds Ram. ---------------------------------------------------------------------- CrazyRam · 2019-07-09 21:07 Quote from: wp on July 09, 2019, 09:22:49 pmQuote from: CrazyRam on July 09, 2019, 07:43:17 pm[...] so I can write a form closure procedure to warn the user that POSTed data has not been save to disk. In this case the Dataset (the ZMSQLQuery) should still be in dsEdit or dsInsert state , certainly not is dsBrowse state 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 TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);begin  if Dataset.State <> dsBrowse then begin    MessageDlg('Data not saved.', mtError, [mbOk], 0);    CanClose := false;  end;end; Hi, this gives me something to work with... As it stands while nothing has been posted it pops up the MessageDLG, but if posted you can still close the form without the data been saved to disk. Rgds Ram. ---------------------------------------------------------------------- CrazyRam · 2019-07-10 00:56 Hi, I missed the obvious for 'Posted' there is a property for the DatasSet to have 'PersistentSave' set to True. When True clicking the 'Post' button saves the change to disk. This in turn works great with your FormCloseQuery WP. Thanks.  Rgds Ram.