procedure CopyData(FrData,ToData:TDataSet;NotCopyField:String;Action:String;isPost:Boolean;isCopySysField:Boolean=False); var I:integer; StrList:TStringList; begin if not (Todata.State in [dsEdit,dsInsert]) then begin if Action = 'I' then ToData.Insert else if Action = 'E' then ToData.Edit end; StrList := TStringList.Create; if not isCopySysField then begin StrList.Add('CMCD'); StrList.Add('CREATEBY'); StrList.Add('CREATEDT'); StrList.Add('EDITBY'); StrList.Add('EDITDT'); StrList.Add('APPROVALBY'); StrList.Add('APPROVALDT'); StrList.Add('STATUSFLAG'); StrList.Add('REVISION'); end; Crlst(StrList,NotCopyField); Try for I:= 0 to Todata.FieldCount -1 do begin if (Todata.Fields[I].DataType <> ftAutoInc) and (Todata.Fields[I].FieldKind = fkData) and (StrList.IndexOf(ToData.Fields[I].FieldName) = -1) and (Frdata.Fields.FindField(Todata.Fields[I].FieldName) <> nil) then begin if not Frdata.Fields.FindField(Todata.Fields[I].FieldName).IsNull then Todata.Fields[I].Value := Frdata.Fields.FindField(Todata.Fields[I].FieldName).Value else Todata.Fields[I].Clear; end; end; if isPost then Todata.Post; Finally StrList.Free; end; end;