If you are persisting the fields of your dataset, you can define an OnSetText Method on your fields.(Doubleclick on the dataset and choose add fields).
The Method could look like this:
procedure TForm1.ADataSetAFloatFieldSetText(Sender: TField; const Text: string);
var
f:Double;
begin
if not TryStrToFloat(Text,f) then
begin
raise Exception.Create(
'Error on: '
+ #13#10'Dataset: ' + Sender.DataSet.Name
+ #13#10'Field: ' + Sender.FieldName
+ #13#10'Old Value: ' + Sender.AsString
+ #13#10'New Value: ' + Text
);
end;
end;
If you want to avoid persisting your fields you can dynamically assign the Method to the field, e.g. after opening the Dataset.
procedure TForm1.ADataSetAfterOpen(DataSet: TDataSet);
Var
i:Integer;
begin
for I := 0 to Dataset.FieldCount - 1 do
begin
if Dataset.Fields[i].DataType in [ftFloat, ftCurrency, ftBCD] then
Dataset.Fields[i].OnSetText := ADataSetAFloatFieldSetText;
end;
end;