TDataset.Delete
Deletes a record from within the named Dataview. Remember, that a Dataview is in-memory only,
Related records within child datasets are not deleted, however they become orphaned and will not therefore be included in any output - so essentially they are deleted.
aRelativeIndex is the position of the record you want to delete, in relation to the currently active record.
To delete the current record, you pass in zero (0) as the parameter. Once the active record has been deleted, the record that was following then becomes the current active record - so if the current active record is for invoice 1001 and you delete that record, then the record which follows for invoice 1002 then becomes the current active record.
To delete the previous record (the record before the current active record), you pass in minus 1 (-1). If the active record is for invoice 1001, then you will be deleting the record for invoice 1000. The current active record remains the current active record.
And to delete the following record (the record after the current active record), pass in one (1). If the active record is for invoice 1001, then you will be deleting the record for invoice 1002. The current active record remains the current active record.
But be mindful of the current active record position - if the current record is the first record or the last record, then you may not be able to delete either before the active record or after the active record.
Declaration: procedure Delete (aRelativeIndex : integer);
Remember, that <DatasetName> in this example is a placeholder, and simply refers to the actual name of your data set as per your Map.
procedure
OnMapEvent(
var
Value:Variant);
begin
//Delete the current record from the dataset
Value := <DatasetName>.Delete(
0
);
end
;
begin
......
<DatasetName>.Delete(
0
);
//Deletes the current active record
......
<DatasetName>.Delete(-
1
);
//Deletes the record before the current active record
......
<DatasetName>.Delete(
1
);
//Deletes the record after the current active record
......
end
;