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

Overall totals of subreports

edited February 2002 in General
I have a Master Detail report. The master tables data is on the main page
of the report. The detail query's data is on the subreport. I have a
summary section on both reports. The summaries are simply DBCalc sum(field)
on both pages.

The summary sections of the details look fine. But the overall summary on
the main report is only summing the first record of each subreport. Can you
tell me what is wrong?

Delphi 5 pro, RB 5.56.


--

Don Gollahon
(gollahon@geneseo.net)

Comments

  • edited February 2002
    Is the DBCalc connected to the master datapipeline? Sounds like it is only
    getting the values based on the traversal of the master data pipeline. Try
    connecting it to the detail datapipeline.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited February 2002
    I'm not sure I follow you. The master and detail are 2 separate tables.
    The DBCalc has to come from the detail datapipeline because that is the only
    place these fields are. I have the dbcalc fields in the summary area of the
    main report to get the sum of all the detail amounts for all detail reords.
    What I get is only the sum of the first detail record attached to each
    master record.

    --

    Don Gollahon
    (gollahon@geneseo.net)

  • edited February 2002
    I totally missed the boat. DBCalcs don't work across subreports, when the
    DBCalc is in the main report. To work around this problem, perform the
    calculation sum in each subreport with a variable and use a variable in the
    summary band of the main report to sum the values from these subreports.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited February 2002
    You can set the value of a variable by using the OnCalc of the variable in
    the subreport.

    procedure TForm1.vblDetailValueCalc(Sender: TObject; var Value: Variant);
    begin
    {increment the detail band running total with the main report variable}
    vblMainTotal.Value := vblMainTotal.Value + 1;

    {display the total in the summary band as well}
    vblSummaryTotal.Value := vblMainTotal.Value;

    {display the new total}
    Value := vblMainTotal.Value;
    end;


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited February 2002
    I ended up adding a second query to get the sums. It works for now. I may
    switch to your method later because that way if the detail query changes in
    some way then I don't have to remember to change the sum query as well.

    Thanks.

    --

    Don Gollahon
    (gollahon@geneseo.net)

This discussion has been closed.