With all the restrictions you set ... No
My advice would be to encode the BeforePost event only once and associate all tables with the same beforepost event.
In the object object
Table1.BeforePost:= TrimFieldsBeforePost; Table2.BeforePost:= TrimFieldsBeforePost; ....
In your code
procedure TMyForm.TrimFieldsBeforePost(DataSet: TDataSet); var i: integer; begin i:= 0; while i < Dataset.Fields.Count do begin if (Dataset.Fields[i].DataType in [ftString, FtMemo, ftFixedChar, ftWideString,FtVariant, ftFixedWideChar, ftWideMemo]) then begin Dataset.Fields[i].AsString:= Trim(Dataset.Fields[i].AsString); end; Inc(i); end; end;
source share