Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-04

Another Master-detail problem

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Koenraad Lelong

Hi,

I think I am doing something fundamentally wrong. Every time I try to do something with master-detail tables, I get stuck on errors I don't understand :-( .

I want to add a record in the detail-table, and modify a field in the master-table. When one of those two goes wrong, I need to revert. So I made this :

qryDetail.Open;
qryDetail.Append;
qryDetailPRICE.Value:=Price;
qryDetailCALIBDATE.Value:=CalibDate;
... other fields of detail are filled
qryMaster.Edit;
qryMasterLASTCALIB.Value:=CalibDate;
try
  qryDetail.Post;
  qryDetail.ApplyUpdates;
  qryToestel.Post;
  qryToestel.ApplyUpdates;
  traMasterDetail.Commit;
except
  qryDetail.CancelUpdates;
  qryMaster.CancelUpdates;
  traMasterDetail.Rollback;
end;

When I remove the master-operations, the detail insert works. My first try did not have the post-statements. The master-update did work, but nothing got inserted in the detail-table. When I added the post-statements, I got an error : qryDetail is not in insert or edit mode.

What am I doing wrong ?
Thanks for any clarification,

Koenraad Lelong.

Reply by email