1
votes

My understanding is that clonedatasets share the same data with their source dataset. When I clone a dataset in insert mode the clone is in browse mode and cant access any field values already set in the source dataset. Is it possible to access the new record from the clone to adjust any of its field values without triggering events such as OnDataChange/OnUpdateData?

using Delphi 7/2010, dbExpress and MySQL.

1
Clone how? TClientDataSet.CloneCursor()? - Marcus Adams
Why can't you post the changed/inserted record in the source dataset before you clone it? All the while the source dataset is in dsEdit/dsInsert state, the change might be cancelled ... - MartynA
TClientDataSet.CloneCursor(SourceCDS, False); I cant post it because the user is still filling in details of the record but i'd like to update some fields based on data already provided. Example: DepositMaster(ID, AmountSUM) -> DepositDetail(ID, Amount) When the user finishes entering all details the Master.Amount is updated with the total of the Detail.Amounts when the user clicks on post. Alternatively the user can fill the Master.Amount and the Detail.Amounts will be inserted automatically based on common entries distributed among the Detail records to equal the Master.Amount. - Martin

1 Answers

2
votes

While a dataset is in insert/edit mode the field values are only stored in the local buffers of the dataset. The Data property from TClientDataSet holding the complete table is only updated when Post is called. That is why there is no access from any cloned dataset to any unposted records.