Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested ClientDataset automatically calls Post after a call to insert.

Status
Not open for further replies.

marflo500

IS-IT--Management
May 16, 2007
36
DM
Hello Everyone,

I have two ClientDatasets in a master/detail relationship (cdsCropType-Master, cdsCrops-Detail) . I have no problems inserting data into the master clientdataset. However when I try inserting data into the Detail clientdataDset the OnAfterPost even handler of the detail clientDataSet is called automatically for reasons unknown to me. This causes the OnReconcileError dialog to pop up indicating that the key field in the newly inserted record of the Detail clientDataset cannot be NULL (because the Detail record is not populated with the necessary data as yet of course). The only field that is populated is the field on which the tables are linked. Is there some way I can prevent the OnAfterPost event handle of the Detail ClientDataSet from automatically getting executed until after I populate the necessary fields of the newly inserted record?

Liam
 
Your wording of the exact sequence is kind of confusing but if I understand correctly, adding an OnBeforePost event should give you the opportunity to insert the required detail field data BEFORE the record gets posted.

Roo
Delphi Rules!
 
Thanks for the tip Roo and sorry for the confusion. Is this the default behavior of Delphi (Calling the OnPost event automatically after the Append or Insert method is called on the Detail Dataset of a Master/Detail relationship)? I am just wondering if there could be some other code that could be triggering this.

Liam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top