Master-Detail Insert New Record. ?How

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Dokkie
Posts: 43
Joined: Wed 08 Oct 2008 21:58

Master-Detail Insert New Record. ?How

Post by Dokkie » Thu 13 Nov 2008 00:50

I've constructed a Master_detail relationship using the mastersource property etc.
As stated in the pdf manual I can add detail records with each record automatically using the master table's linking field value. This only works if the master record already exists.

I'm having trouble with inserting a new Master table and it's associated detail table. Even if I set the generator property in the Master table it's not picked up by the detail table.
I've tried Posting the Master table then posting the Detail table it's still not picked up.
I can set the link field value On the OnNewRecord event but I'm wondering if I'm misunderstanding how this is supposed to work - when inserting a new Master record with a new related detail record.

Peter

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 13 Nov 2008 08:57

You should insert and post a record in the master table. Make sure that the key field in the master table has a value after posting.

Then you can insert detail records. These records will take value for the linked field from the master table.

Post Reply