Subject | Master-Details Foreign Key |
---|---|
Author | Vincenzo Scarpellino |
Post date | 2004-10-18T14:35:54Z |
IBO 4, FB 1.5
Hi,
In my application I have two queries (TIBOQuery RequestLive=True), a Detail Query linked by a Foreign Key to a Master Query. When I insert a new record I post Master Query and set it in Edit State before to post first row of Detail Query to avoid Foreign Key Error. Now I am trying to write a little component, inherited from TIBOQuery, with a Property AutoEditMaster. When this property is True detail query in Before Post Event (Master Query is in Insert State) post and edit it.
procedure TEurIBODetailQuery.DoBeforePost;
begin
if AutoEditMaster and
(DataSource <> nil) and
(DataSource.State = dsInsert) then
begin
try
Screen.Cursor:= crSQLWait;
DataSource.DataSet.DisableControls;
DataSource.DataSet.Post;
DataSource.DataSet.Edit;
finally
Screen.Cursor:= crDefault;
DataSource.DataSet.EnableControls;
end;
end;
inherited;
end;
When it perform "DataSource.DataSet.EnableControls" Detail query is closed unexpected. It seems loose relation key, when I reopen it, that record was posted right. I tried to move EnableControls to test it in AfterPost and It work fine, of course until there are no exceptions. I don't know how resolve this problem to avoid user post and edit Master Query manually.
Every suggestions or experience about a different method will be appreciated.
Thank You
Best Regards
--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f
Sponsor:
Con LINEAR Assicurazioni puoi risparmiare fino al 40% sulla tua polizza RCAuto senza rinunciare alla qualità e all’assistenza del gruppo UNIPOL.
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid'15&d-10
[Non-text portions of this message have been removed]
Hi,
In my application I have two queries (TIBOQuery RequestLive=True), a Detail Query linked by a Foreign Key to a Master Query. When I insert a new record I post Master Query and set it in Edit State before to post first row of Detail Query to avoid Foreign Key Error. Now I am trying to write a little component, inherited from TIBOQuery, with a Property AutoEditMaster. When this property is True detail query in Before Post Event (Master Query is in Insert State) post and edit it.
procedure TEurIBODetailQuery.DoBeforePost;
begin
if AutoEditMaster and
(DataSource <> nil) and
(DataSource.State = dsInsert) then
begin
try
Screen.Cursor:= crSQLWait;
DataSource.DataSet.DisableControls;
DataSource.DataSet.Post;
DataSource.DataSet.Edit;
finally
Screen.Cursor:= crDefault;
DataSource.DataSet.EnableControls;
end;
end;
inherited;
end;
When it perform "DataSource.DataSet.EnableControls" Detail query is closed unexpected. It seems loose relation key, when I reopen it, that record was posted right. I tried to move EnableControls to test it in AfterPost and It work fine, of course until there are no exceptions. I don't know how resolve this problem to avoid user post and edit Master Query manually.
Every suggestions or experience about a different method will be appreciated.
Thank You
Best Regards
--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f
Sponsor:
Con LINEAR Assicurazioni puoi risparmiare fino al 40% sulla tua polizza RCAuto senza rinunciare alla qualità e all’assistenza del gruppo UNIPOL.
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid'15&d-10
[Non-text portions of this message have been removed]