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

How to omit GroupFooterBand if DetailBand has only 1 record

edited January 2005 in Subreports
Hi,

I have a Main / DetailBand report that has a Group Header/Footer.
The Header must always be displayed, and the Footer contains a totals line,
and also a DBCalc field which is a Count() of the number of records in the
group, e.g.

Client Name (group header)
(then detail band....)
record 1 ?10.00 ?10.00 ?0.00
record 2 ?0.00 ?0.00 ?20.00
record 1 ?0.00 ?10.00 ?10.00
(then group footer....)
===== ===== =====
Totals for this Client 3 records ?10.00 ?20.00 ?30.00

When the report design is finished, the footer will contain 4 !! consecutive
lines of totals, and so could potentially use many more pages than
required - but there is little point in printing the totals when the group
contains ONLY 1 record, so I want to prevent the Totals printing when only 1
record is listed.

I am trying to do this by monitoring the DBCalc field, and then setting the
visibility of the Footer along the following lines:-

procedure
Tform_rpt_mat_lst_clt_acc_bal.ppGroupFooterBandBeforeGenerate(Sender:
TObject);
begin
if SLSRBDBCalc6.Value > 1 then
ppGroupFooterBand2.Visible := True
else
ppGroupFooterBand2.Visible := False;
end;

However the procedures do not seem to be run atall. I have set a breakpoint
and run to debug and it doesn't enter this procedure.
I have tried "BeforeGenerate" and "BeforePrint" and even OnCalc on the
DBCalc field, but I don't understand why it isn't entering the procedures.
Otherwise the report runs fine and produces the Group information correctly.

Can you please advise what I am doing wrong, or if there is a better way to
achieve this?

Thanks
James Prior

Comments

  • edited January 2005

    You need to use the GroupFooter.BeforePrint event.

    I tried a simple test here and it worked.

    If the event does not fire, then perhaps the event-handler method is not
    assigned to the GroupFooter band.



    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.