If you save the fields of your dataset, you can define the OnSetText method in your fields. (Double-click on the dataset and select add fields).

The method might 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 saving your fields, you can dynamically assign a method to a field, for example. after opening the data set.
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;
bummi source share