HELP: Master-detail form: sequence of detail records 
Author Message
 HELP: Master-detail form: sequence of detail records

When viewing a master-detail screen, I find that the records in
the detail table, viewed via a DBGrid component, are not presented
in the correct sequence of the (detail) tables primary index.

Why is this so?

I have tried to set the index within the code,
but get an Index Range Error.  Could anyone please advise what
property settings need to be set to accomplish this requirement,
otherwise a code fix.

Many thanks.



Fri, 01 Jan 1999 03:00:00 GMT  
 HELP: Master-detail form: sequence of detail records

On Monday, July 15, 1996, "James D (Jim) Duff" wrote...

Quote:
> When viewing a master-detail screen, I find that the records in
> the detail table, viewed via a DBGrid component, are not presented
> in the correct sequence of the (detail) tables primary index.

> Why is this so?

> I have tried to set the index within the code,
> but get an Index Range Error.  Could anyone please advise what
> property settings need to be set to accomplish this requirement,
> otherwise a code fix.

> Many thanks.

Jim,
     I had exactly the same problem and decided to use a different
approach.  Instead of using the mastersource property to tie the tables I
leave them separate.  From the master table use the field that links the
two tables to set the range using SetRangeStart.  Then increment the value
for SetRangeEnd.  Now when you call ApplyRange, only those detail records
that fall in the range will be visible.  There is also a SetRange method
that combines the calls for all three methods into one.  The following is
text for Delphi's Help file:

"Applies to
TTable component

Declaration
procedure SetRange(const StartValues, EndValues: array of const);

Description

The SetRange method combines the functionality of the SetRangeStart,
SetRangeEnd, and ApplyRange methods. SetRange assigns the elements of
StartValues to the beginning index key, the elements of EndValues to the
ending index key, and then calls ApplyRange. This enables an application
to filter the data visible to the dataset.
If either StartValues or EndValues has fewer elements than the number of
fields in the current index, then the remaining entries are set to NULL.

Note:   With Paradox or dBASE tables, these methods work only with indexed
fields. With SQL databases, they can work with any columns specified in
the IndexFieldNames property."

With the mastersource property now blank, you can assign the desired index
to the detail table and your sort will be correct.
Hope this helps.
--
Evertt Byington
USU Internal Audits

Phone:  (801) 797-1085  FAX:  (801) 797-1700



Fri, 01 Jan 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Sorting detail records in a master detail relation.

2. Problem when inserting records in the detail table (master/detail relation)

3. Deleting records in master-detail database form

4. Database detail form <= master form

5. Master-Detail : Sorting Detail?

6. Master - Detail - Detail queries & DBGrids

7. Setting report variables in the detail of a ReportSmith master-detail report

8. Master-detail-detail-detial with Cascade delete

9. Master/Detail lookup - losing detail field

10. Changing Key Fields in Master Record without Orphaning Detail Records

11. Newbie - updating Detail in master-detail

12. Sequencing detail records: any ideas?

 

 
Powered by phpBB® Forum Software