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

Make a subreport conditionally invisible

edited September 2005 in General
Hi,
If the DB calc (sum) in the summary of a subreport is = zero then I want to
make the entire subreport invisible.
How do I do this?

I tried:
===
procedure SubReport1OnPrint;
if DBCalc1.Value = '0' then
SubReport1.Visible := true
else
SubReport1.Visible := false;
===

but got the error:

Error: SubReport1OnPrint, Line 4: Undeclated Identifier: 'SubReport1'.

What am I doing wrong?

Thanks
Redmond

Comments

  • edited September 2005
    Hi Red,

    Try using the Band.BeforePrint event of the main report to set the
    visibility of the Subreport. Setting the subreport's visibility inside the
    subreport will not give you the results you are after.

    --
    Regards,

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

    Best Regards,

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

    Thanks, but the problem I have is that the DBCalc on which the condition
    rely's upon is IN the subreport, so I now get the error:

    Error: ReportBeforePrint, Line3: Undeclared Indentifier: 'DBCalc1'.

    Thanks
    Redmond



  • edited September 2005
    Hi Red,

    Unfortunately once the subreport has begun the generation process, it is not
    possible to set it's visiblity. I would recommend calculating this sum
    before printing the report perhaps with a separate query or in Delphi code,
    then using this information to determine whether the subreport is visible or
    not.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.