Scalabium Software

SMExport advertising

Knowledge for your independence.
Home Delphi and C++Builder tips



#63:How can I copy (dublicate) the dataset record?

In some apllications, in which user must add a lot of the records in the dataset, very useful the "copy record" mode.

For example, the operator added the new record and must add the new, but this second record is "similar" to first and only few attributes are different. In this case, I use the possibility to dublicate the values of the wished record, insert a new record and open the dialog for editing these values.

Those from you, who uses the my freeware TSMDBNavigator component, saw the new additional Copy button with the next handler:

procedure TSMDBNavigator.CopyRecord;
var varCopyData: Variant;
    i: Integer;
begin
  with DataSource.DataSet do
  begin
    varCopyData := VarArrayCreate([0, FieldCount-1], varVariant);
    for i := 0 to FieldCount-1 do
      varCopyData[i] := Fields[i].Value;

    Insert;

    for i := 0 to FieldCount-1 do
      Fields[i].Value := varCopyData[i];
  end;
end;

So you can assign to the TSMDBNavigator.OnEditRecord event the dialog opening for record edit. In this event I pass the second parameter: is copy mode or edit mode only.

Of course, you can cut this procedure and use this code for run-time record dublication without using TSMDBNavigator component. Also you can modify it and exclude the wished fields (for example, autoincremental fields).

See also
 
SMExport suite
SMImport suite
SMReport
SMDBGrid
MAPIMail
Paradox Viewer
Paradox ActiveX
ExcelFile Viewer
Metafile Convert
DBLoad
DBExport tools
 
 
Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyrightc 1998-2008, Scalabium Software. All rights reserved.
webmaster@scalabium.com

January 26, 2000

SMReport Autogenerated