Board index » delphi » Editing master record in master/detail relationship

Editing master record in master/detail relationship

Problem:

1. I edit detail record.
2. I edit master record.

Why will I lose my changes, that I have made to detail record?
Immediately after edit of master-query, all detail queries (TQuery) will be
opened again and then will I lose all changes made to detail records.
What is the easiest way to handle this?

 

Re:Editing master record in master/detail relationship


Hi Aki!

On Tue, 20 Jul 1999 15:52:02 +0300, "Aki Mustonen"

Quote
<aki.musto...@tieto.com> wrote:
>Why will I lose my changes, that I have made to detail record?
>Immediately after edit of master-query, all detail queries (TQuery) will be
>opened again and then will I lose all changes made to detail records.
>What is the easiest way to handle this?

That's the way it goes. You should invoke master dataset edit method
on Before edit/insert/delete of detail record if you want to be able
to edit master and detail in the same time and post the changes in one
go.

Also note that you can edit only one master record and it's many
detailed records. If you skip your master record you again loose your
changes in detail.

If you do not like that scheme and you want to edit more than one
master/detail pair than you should manage master/detail relationship
yourself in the code - the best thing to do is select all the detail
data and filter it on master dataset data change. But than you have
problems if detail table is very long because you loose TQuerys
selection of just the records needed.

tomi.

Other Threads