I have a TZTable (ZEOSlib) bound to a DBGrid now I need to know which particular TField was changed by the user.
I tried with
if NOT (taPositionenArtNrGH.NewValue = taPositionenArtNrGH.OldValue) then
ShowMessage('ArticleNumber changed');
I placed the code in
But in the Debugger OldValue is always NewValue. How do I check which field was changed?
You can use UpdateStatus : TUpdateStatus
for this. For example:
In OnCalcFields event use:
procedure TDM1.ZTable1CalcFields(DataSet: TDataSet);
begin
if ZTable1.UpdateStatus in [usModified] then
begin
ZTable1Status.value := 'Modified';
ZTable1FNameOldValue.value := ZTable1FNAME.OldValue;
end
else
ZTable1Status.value := 'UnModified'
end;
Result :
Edit:
You can detect field level changes like:
if ZTable1.UpdateStatus in [usModified] then
begin
for I := 0 to ZTable1.Fields.Count - 1 do
begin
if ZTable1.Fields[i].OldValue <> ZTable1.Fields[i].NewValue then
-- do something with this field
end;
end;