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

How to do a one master multiple details report?

edited December 2005 in General
Hi,

I need to do a report with one master, two details, then one one detail will
have sub-detail. So it is not a master - detail - subdetail report.

I have gotten the master - detail - subdetail working. But I couldn't
figure out how to add the second detail to it. I add a query and a
datasource. The query references the master datasource as its
masterdatasource. I add a dbpipeline to reference the second details
datasource. And reference the master pipelink as its master. Then in the
report, I add another subreport to the detail band of the master data and
make it shiftrelative to the subreport of the first detail. It prints the
first detail (and the subdetails) then the second detail. However, it
repeats as many time as the record count of the second detail (I limited the
record return by the second detail to 3 and the report repeats the two
subreports 3 times, then it stops without printing any subsequent master
records.

So how to do one master multiple details report with RB?

Thanks,
Ping Kam

Comments

  • edited December 2005
    Hi Ping,

    How are you linking the second detail dataset to the master? You need to be
    sure that the linking field has a one to many ratio from master to detail,
    and that the detail dataset is ordered on the linking field. Take a look
    at the following example of how to have one master with three details.

    http://www.digital-metaphors.com/tips/MasterThreeDetails.zip

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2005
    Hi Nico,

    I download your sample project, but I got error when loading the project, I
    don't have the DBDemos database installed.

    Now back to my problem. My detail dataset uses parameter in the SQL to
    retrieve only the detail records of the current master record.

    The SQL of the detail query looks like this:
    select fieldlist from detail_table where masterkey = :masterkey.

    And the master dataset and detail dataset are linked by the datasource so
    the detail dataset will refresh when the master dataset scrolls, therefore
    the detail dataset only contains the detail records of the current master
    record and nothing else. So I don't see any need to order the detail
    dataset.

    Will this cause a problem? It seems to work fine if I have only one detail
    dataset, but not when I add another detail dataset.

    I also notice that the master scrolls more often than it should when I
    monitor its OnScroll event. Is there a reason why the masterdataset's
    OnScroll event fires so many times during the report? Is there a way to
    prevent the master from scrolling only when it really moves to the next
    record? This may be a performance problem if the detail datasets get
    refresh so many times.

    Thanks,
    Ping Kam

  • edited December 2005
    Hi Nico,

    I seem to find the problem. I didn't include the masterkey field in the
    selected field list, like:

    select field1, field2 from detail_dataset
    where masterkey = :masterkey

    When I look at the MasterFieldLink property of the Pipeline, the masterkey
    is not listed. I believe that the Pipeline is unable to build the link. I
    add the master key field to the selected field list and it seems to work
    now.

    select masterkey, field1, field2 from detail_dataset
    where masterkey = :masterkey

    Now the only problem left is the page no does not reset to 1 in the
    OnStartPage event in the first pass. I also have some concern on the master
    being scrolled more often than required.

    Ping Kam

This discussion has been closed.