Вычисляемое поле SQLQuery1 lazarus / 16-Databases ---------------------------------------------------------------------- maxika · 2018-09-08 16:35 Hello, tell me please how to make an automatic calculation of the calculated field SQLQuery1, when changing another numeric field. When I do this: procedure TForm1.SQLQuery1Поле1Change(Sender: TField); begin SQLQuery1.FieldByName('ВычислПоле') .AsInteger:=SQLQuery1.FieldByName(' Поле1').AsInteger * 2; end; The auto save function stops working: procedure TForm1.SQLQuery1AfterPost(DataSet: TDataSet); begin SQLQuery1.ApplyUpdates; end; Please tell me how to do it correctly. ---------------------------------------------------------------------- lucamar · 2018-09-08 18:18 Shouldn't ApplyUpdates be called much earlier? IIRC, in AfterPost the dataset is already updated. Maybe you should try to set the calculated field(s) and call ApplyUpdates in an OnBeforePost handler? ---------------------------------------------------------------------- maxika · 2018-09-09 14:24 thank you very much for the help the following methods create an auto-calculation field and autosave data procedure TForm1.SQLQuery1BeforeScroll(DataSet: TDataSet); begin   SQLQuery1.Edit;   SQLQuery1.FieldByName('AAA').AsInteger:=SQLQuery1.FieldByName('BBB') .AsInteger*2;   SQLQuery1.Post; end;  procedure TForm1.DBNavigator1Click(Sender: TObject; Button: TDBNavButtonType); begin   if Button = nbPost then    begin      SQLQuery1.Edit;      SQLQuery1.FieldByName('AAA').AsInteger:=SQLQuery1.FieldByName('BB B').AsInteger*2;      SQLQuery1.Post;    end; end;    procedure TForm1.SQLQuery1AfterPost(DataSet: TDataSet); begin   SQLQuery1.ApplyUpdates; end; ---------------------------------------------------------------------- sash · 2018-09-09 22:08 Usually for calculated fields (TFieldKind = fkCalculated) they use OnCalcFields. But seems like you're using regular fields, so: don't (ever) use for such purpose BeforeScroll DBNavigatorClick use 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.SQLQuery1BeforePost(DataSet: TDataSet);begin  SQLQuery1.FieldByName('AAA').AsInteger := SQLQuery1.FieldByName('BBB').AsInteger*2;end;    procedure TForm1.SQLQuery1AfterPost(DataSet: TDataSet);begin  SQLQuery1.ApplyUpdates;end;   p.s. Заголовки лучше писать по Английски.