I use TZQuery.OncalcFields, if I call TZQuery.Refresh then OncalcFields executed twice.
Do anyone know, why the is executed twice?
This is my code:
procedure TForm1.QuZCalcFields(DataSet: TDataSet);
begin
//Saldo is Currency
// QuZSOLL and QuZHABEN are fields of this query
Saldo:=QuZSOLL.AsCurrency-QuZHABEN.AsCurrency+Saldo;
//Only QuZSALDO is CalcField
QuZSALDO.AsCurrency:=Saldo;
//ZBS ist autoinc
Memo1.Lines.Add(TimeToStr(now)+' - #BS: '+QuZ.FieldByName('ZBS').AsString+' - S: '+Format('%.2n', [saldo]));
end;
And here is log output after calling QuZ.Refresh;
18:01:08 - #BS: 1 - S: 50,00
18:01:08 - #BS: 2 - S: 550,00
18:01:08 - #BS: 3 - S: 550,00
18:01:08 - #BS: 4 - S: 610,00
18:01:08 - #BS: 5 - S: 640,00
18:01:08 - #BS: 1 - S: 690,00
18:01:08 - #BS: 2 - S: 1.190,00
18:01:08 - #BS: 3 - S: 1.190,00
18:01:08 - #BS: 4 - S: 1.250,00
18:01:08 - #BS: 5 - S: 1.280,00