Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IBTable Master-Detail relationships.

15 views
Skip to first unread message

Will

unread,
Jun 9, 2004, 6:32:50 PM6/9/04
to
I'm putting together a little test app to help me figure some stuff out.
Something, that I thought would be simple, doesn't appear to be as simple as
I thought, or else I'm missing something.

Anyway, if I set up a Master/detail relationship at design time, then view
it in the running test app, it works the way I think it should. Cycle
through the master, and the detail changes as necessary. However, when I try
to set the properties, those that appear to be modified at design time by
the Object Inspector, at runtime, the M/D no longer works.

I have a form, with one grid per table. The topmost grid is the master
table, the remaining four are detail tables. At design time, I set the
Database and TableName properties of the master table, then associate a
TDatasource with it. Then, I take each of the remaining four TIBTable
components, setting their TableName, Database properties, and then the
MasterSource property to the TDataSource associated with the Master table.
Then, when I click the ellipsis on the MasterFields property, a small dialog
appears, from which I pick the two fields that join the tables, and click
OK. This then adds the MasterTable key to the MasterFields property, and
sets the IndexFieldNames to the Detail table's key. When I run the program
and scroll through the Master tables records, the remaining four grids
change their display as the Master changes.

Now, this is nice, but I have a choice of three potential Master tables. So,
what I want to do is to change the Master at runtime, which should only
require the changing of the Detail table's MasterFields property. When I do
that at runtime, and scroll through the Master table, the other 4 grids do
nothing. This obviously is not what I want.

Below is the code that changes the MasterFields property:

// set these to nil, so that no errors occur while changing property
values
tblAddress.MasterSource := nil;
tblEmail.MasterSource := nil;
tblPhone.MasterSource := nil;
tblEvent.MasterSource := nil;
// change the property to the key of the new table
tblAddress.MasterFields := 'EEMPLOYEEID';
tblEmail.MasterFields := 'EEMPLOYEEID';
tblPhone.MasterFields := 'EEMPLOYEEID';
tblEvent.MasterFields := 'EEMPLOYEEID';
// close the Master table, change the table, then reopen
tblEntity.Close;
tblEntity.TableName := 'EMPLOYEE';
tblEntity.Open;
// reassociate the details tables with the mastersource table
tblAddress.MasterSource := dsEntity;
tblEmail.MasterSource := dsEntity;
tblPhone.MasterSource := dsEntity;
tblEvent.MasterSource := dsEntity;

What am I missing?

Thanks.

--
Will


Will

unread,
Jun 9, 2004, 7:10:06 PM6/9/04
to
Got it.

--
Will


Bill Todd (TeamB)

unread,
Jun 9, 2004, 8:22:24 PM6/9/04
to
On Wed, 9 Jun 2004 16:10:06 -0700, "Will" <dragoo...@hotmail.com>
wrote:

>Got it.

Not really. :) Do not use TIBTable. The component exists to make
converting applications from the BDE easy but it causes serious
performance problems with tables of any size. Use TIBDataSet instead.
You should also read
http://community.borland.com/article/0,1410,28160,00.html

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Will

unread,
Jun 18, 2004, 2:59:29 PM6/18/04
to

"Bill Todd (TeamB)" <n...@no.com> wrote in message
news:g3afc0pbuiak2sp8u...@4ax.com...

Thanks for the link. Interesting reading.

--
Will


0 new messages