BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Related record in master table

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (ADO)
View previous topic :: View next topic  
Author Message
Ney André de Mello Zunino
Guest





PostPosted: Sat Jun 03, 2006 8:43 pm    Post subject: Related record in master table Reply with quote



Hello.

In an application, I have a form which displays a master/detail
relationship on 2 DBGrids. The underlying data set for both grids are
TADOQuery objects. In order to synchronize the details grid with the
currently selected record on the master grid, I use the master's data
set's /AfterScroll/ event. The handler for that event first stores the
id of the currently selected master record (to be used when inserting
detail records), then used that id as a parameter to the details' query.

So far, so good. The problem comes when trying to add detail records.
Here is the scenario: I open the form and click on a master record with
no associated detail records. The first thing I noticed is that the
details grid shows an empty row, even though there are no records. I
suppose that's by design. Anyway, trying to enter information on that
row and posting it would cause the following error:

"You can not add or change a record because a related record is
required in table Master Table"

Ok, so it is telling me that I need to provide the "foreign key" field
(within quotes because, AFAICT, Access does not provide FK ref.
integrity control). Because I also noticed that, once I started editing
the columns on the grid, the details' datasource would change into the
/dsInsert/ state, I added code to its /OnStateChange/ event that would
put the ID of the selected master record into the "FK" field on the new
detail record. However, when I try to post that new record, I still get
the same error.

Would anybody be kind enough to help me understand this situation. I
could understand the initial error, but I don't know why it persists
even after I provide the id of the master record.

Thank you very much,

--
Ney André de Mello Zunino
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.