Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Subreport does not return control to main report.

edited August 2002 in General
I have a report with a M-D relationship created using 2 queries. Master
(Billing) has individual recs sorted on LoanKey, Detail has a list of
all detail recs also in LoanKey order. The LoanKey in Master (unique)
and Detail are the link between the records in Master and the groups in
Detail.

The message I had pulled this from said that I could do M-D reports with
std M-D quuries and keep refetching blocks of records for the detail. Or
us 2 queries in which the detail has records for all groups and sorted
in group order. The second option is what I am trying to do.


The report should print the pages as:
Master Rec1 (one page)
Detail for detail data with Key matching MasterRec1 key (1+ pages)
Master Rec2 (one page)
Detail for detail data with Key matching MasterRec2 key (1+ pages)
Master Rec3 (one page)
Detail for detail data with Key matching MasterRec3 key (1+ pages)
etc.

The Master is always only a single page. The main report's detail is to
print on pages following the page for each master record. This is a
1:many situation.

The main report prints as a grouping on the LoanKey field to allow the
first page of each grouping to print the summary data from the master
table (Billing) using the GroupHeader band and then the detail from the
group is supposed to print from the subreport and its linked detail
table.

The detail is attached to a sub-report which groups on the same key
field (in the detail Detail.LoanKey) as the master uses
(Master.LoanKey). Here is the M-D setup which I got from a previous DM
support message.

FBillingDM.OpenPrintData;
FLoanTranDM.OpenPrintData;
BillingsDS.DataSet := FBillingDM.PrintData;
TranHistDS.DataSet := FLoanTranDM.PrintData;
// Create the M-D link
TranHistPL.MasterDataPipeline := BillingPL;
IFieldLink := TppMasterFieldLink.Create(nil);
IFieldLink.Parent := TranHistPL;
IFieldLink.DetailFieldName := 'LoanKey';
IFieldLink.MasterFieldName := 'LoanKey';
FBillingDM.PrintData.First;
FLoanTranDM.PrintData.First;

This same concept is working fine in another report, except in that
report the detail only has one record per master (1:1 relation).

Here my master report prints the first page OK and then the detail
starts printing. Detail prints the groups as it should (even breaking
pages between the groups) but conrol never returns to the main report
(between each group) to get the next master record and reprint the main
reports group headings.

Band Structure looks like this:

Header (which needs to print on every master and subreport page)
GroupHeader[0] (which needs to print only on the master pages)
DetailBand
Contains a subreport (pbChild: DetailReport)


DetailReport:
Properties:
TraverseAllData=False
PrintBehavior=pbChild
ParentWidth=TRUE
DataPipeline=TranHistPL

GroupHeader1Band
SubReportDetailBand


Groups are line this:

Group1 (Master)
BreakName=HiddenLoanKeyForMainBreak
BreakType=btCustomField
DataPipeline=TranHistPL
HeaderForOrphanedFooter=TRUE
KeepTogether=FALSE
NewColumn=FALSE
NewPage=TRUE
ReprintOnSubsequentColumn=TRUE
ReprintOnSubsequentPage=FALSE
ResetPageNo=TRUE

HiddenLoanKeyForMainBreak is a ppDBTextField on the main report's Header
band with Billing.LoanKey as datafield and set Visible=FALSE.


Group2 (Detail)
BreakName=HiddenDBLoanForGroup
BreakType=btCustomField
DataPipeline=TranHistPL
HeaderForOrphanedFooter=TRUE
KeepTogether=FALSE
NewColumn=FALSE
NewPage=TRUE
ReprintOnSubsequentColumn=TRUE
ReprintOnSubsequentPage=TRUE
ResetPageNo=FALSE

HiddenDBLoanForGroup is a ppDBTextField on the SubReport's DetailBand
with TranHist.LoanKey as datafield and set Visible=FALSE.

NewPage is set TRUE on the SubReport's group to get the detail to print
on pages 2+. The first page of each Master group is for the group
summary data that is pulled from the Billing.PrintData dataset.


My Pipelines are set up as:
AutoCreateFields=TRUE
CloseDataSource=FALSE
OpenDataSource=FALSE
RangeBegin=rbFirstRecord
RangeEnd=reLastRecord

Master has SkipWhenNoRecords=TRUE
Detail has SKipWhenNoRecords=TRUE

So with al this in mind, why is my master pipeline not skipping through
the records??

Allen.

Comments

  • edited August 2002
    If you are going to use this approach, then you need to link the
    datapipelines using the MasterFieldLinks and MasterDataPipeline properties.
    This has to be done in order to let the report engine know that it has a
    master detail datapipelines to traverse. Do you have RB Professional or
    Enterprise? If you do, then you can create the query in DADE, and then copy
    the detail magic SQL (crtl-click over a detail dataview) to your query
    component on a form, just to see what the SQL should be. You are right, you
    have to order the detail by the key linking field and also any order by's
    from the master.

    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited August 2002
    Im my original msg below I indicated that I WAS linking the
    datapipelines using the MasterFieldLinks and MasterDataPipeline
    properties.

    I WAS pulling the datasets in the same orders.

    Using RB Pro.

    So any idea WHY this is not working or where I can check to see what is
    going wrong?

    Thanks,

    Allen.

    In article <3d69845b$1@dm500.>, "Jim Bennett \(Digital Metaphors\)"
  • edited August 2002
    Sorry, missed that. Try connecting the datasets up to a dbGrid on a form to
    see the data that is coming through. Is it in the correct order? Is the
    main report connected to the master datapipeline? Is the subreport connected
    to the detail datapipeline? It should work if the detail dataset is
    configured correctly and the pipeline links are defined correctly. As you
    say you have it wokring in another report. If it still doesn't work, then
    send an example to support@digital-metaphors.com and we'll take a look at
    it.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    In article ,
    allen@nisinc.com says...

    Problem had to do with the datasets grouped by the same value but not
    necessarily IN the same order.

    Allen.
This discussion has been closed.