Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Sorting Details in Master/Detail setup
Wed, Feb 25 2009 11:32 PMPermanent Link

Pat
Hi all,

I have a Master/Detail setup and it works fine

- tblDetail.MasterSource = dsMaster
- tblDetail.MasterFields = link index between the 2 Master/Detail
tables
- the tblDetail.IndexName gets setup by the Field Link Designer

so when I have 2 grids and select a record in the Master grid, the
correct records are displayed in the Detail grid.

Problem is I want to sort/display the Detail grid by another index
that the Detail table has.

Is there an east way to do this? because changing the Detail's
IndexName (to another index) looses the Master/Detail linking.

Maybe have a third table (say tblDisplayRecords) so when I select a
different Master record, it copies the resultant Detail table records
to tblDisplayRecords and then sort/show these records in a grid? If
this is the case, I use the tblMaster.AfterScroll event to trigger the
copying of the Detail records?

Thanks,
Pat
Thu, Feb 26 2009 12:06 AMPermanent Link

"Robert"

"Pat" <pat@downunder.com> wrote in message
news:5m6cq491lddj4k7j9bue8ga90ppnk7q0n9@4ax.com...
>
> Problem is I want to sort/display the Detail grid by another index
> that the Detail table has.
>
> Is there an east way to do this? because changing the Detail's
> IndexName (to another index) looses the Master/Detail linking.
>

Use a query instead of a ttable for the detail. Then you can sort it any way
you want.

SELECT * FROM DETAILS WHERE DETAIL_FOREIGN_KEY = :MASTER_KEY ORDER BY
MYFIELD DESC

You will have to enter the master datasource in the query's datasource
property. Please note that in the SQL above :MASTER_KEY is a parameter.

It's not going to be as fast as using a ttable.

Robert

Thu, Feb 26 2009 6:05 AMPermanent Link

Jan Ferguson

Data Software Solutions, Inc.

Team Elevate Team Elevate

Pat,

I use a compound index in a situation such as this. Simply create a new
index using the original field and then add the second field you want
to index on. For example, if your Master/Detail linking index field is
"RecordID" and you want to sort by the Detail field of "Date", create
an index using "RecordID" first followed by "Date". I usually name the
index appropriately, like "RecordDate".

This will accomplish what you want to do.

--
Regards,
Jan Ferguson [Team Elevate]


Pat wrote:

<<Hi all,
<<
<<I have a Master/Detail setup and it works fine
<<
<<- tblDetail.MasterSource = dsMaster
<<- tblDetail.MasterFields = link index between the 2 Master/Detail
<<tables
<<- the tblDetail.IndexName gets setup by the Field Link Designer
<<
<<so when I have 2 grids and select a record in the Master grid, the
<<correct records are displayed in the Detail grid.
<<
<<Problem is I want to sort/display the Detail grid by another index
<<that the Detail table has.
<<
<<Is there an east way to do this? because changing the Detail's
<<IndexName (to another index) looses the Master/Detail linking.
<<
<<Maybe have a third table (say tblDisplayRecords) so when I select a
<<different Master record, it copies the resultant Detail table records
<<to tblDisplayRecords and then sort/show these records in a grid? If
<<this is the case, I use the tblMaster.AfterScroll event to trigger the
<<copying of the Detail records?
<<
<<Thanks,
<<Pat
>>

Pat
Thu, Feb 26 2009 3:55 PMPermanent Link

Pat
Robert,

>Use a query instead of a ttable for the detail. Then you can sort it any way
>you want.

never thought to use a query in that way, thanks

Pat
Thu, Feb 26 2009 3:59 PMPermanent Link

Pat
Jan,

>I use a compound index in a situation such as this. Simply create a new
>index using the original field and then add the second field you want
>to index on.

sorts OK now, thanks Wink

Pat
Image