Subject Re: [IBO] Duplicate a record
Author Harald Klomann
Thanks, this is much better !

Harald



Chef wrote:

> Harald,
>
> just a suggestion, I use "RowData" for this task:
>
> procedure TM_DM_PlannerCfg.DuplicatePlanCol( ID_PlanCol: Integer );
> var
> sRowData: String;
> begin
> with Qry_PlanCol do begin
> Locate( 'PC_ID_PLANCOL', ID_PlanCol, [] );
> sRowData := Fields[0].Row.RowData;
> Insert;
> Fields[0].Row.RowData := sRowData;
> FieldByName( 'PC_ID_PLANCOL' ).AsInteger := GeneratorValue(
> 'GEN_PC_ID_PLANCOL', 1 );
> Post;
> end; // with
> end;
>
> HTH,
> Markus
>
> At 15:13 20.11.00 +0100, you wrote:
> >Hi,
> >
> >I want to append a new record, with the all the values assigned from the
> >current record in a grid.
> >My code works, but is there a better method to do this ?
> >
> >
> >procedure TfrmDemo.Button1Click(Sender: TObject);
> >var i:integer;
> >begin
> > with IB_Query1 do begin
> > i := FieldByName('ID').AsInteger;
> > Append;
> > KeyFields.ByName('ID').AsInteger := i;
> > if LookupKeyForBufferFields then begin
> > for i := 0 to FieldCount-1 do Fields[i].Assign(BufferFields[i]);
> > post
> > end;
> > end;
> >end;
> >
> >
> >Thanks
> >Harald Klomann
>