Home General

Emulate a subreport by hiding/showing the detail band?

edited February 2010 in General
Good morning,

I have a report I created where I hid the detail band and am only showing
the totals in the Group Header. I'm trying to figure out a way to make the
individual detail band show or hide when the user clicks on an image,
similar to the way subreports are shown or hidden. I know I can use a
subreport to achieve this, but since the data is already in the report, it
seems redundant to do it that way. I tired using the following event with
the image, but it won't compile (Undeclared identifier: 'ppReport1'):

procedure Image2OnDrawCommandClick(aDrawCommand: TObject);
begin
if not Detail.Visible then Detail.Visible := True else Detail.Visible :=
False;
ppReport1.Reset;
ppReport1.Engine.Reset;
TppDrawText(aDrawCommand).RedrawPage := True;
end;

(Using 'ppDetailBand1.Visible' instead of just 'Detail.Visible' results in
'ppDetailBand1' being called an undeclared identifier too)

I don't want ALL of the detail bands to show when the user clicks on the
image, just the details for that one group.

If I have to use a subreport, do I need to create a duplicate data view
linked to the main one to get it to show only records in the group or is
there some way to use the same data pipeline?

Steve

Comments

  • edited February 2010
    Hi Steve,

    The code you have below will set the detail band's visible property to True
    then regenerate the entire report (showing all detail bands). If you need
    to limit the number of detail bands shown, you may want to implement
    something similar to a drilldown report using subreports as you mention.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2010
    Thank you. That's what I expected. As I was typing my question in, I
    realized that since I was trying to show the details for only a specific
    group, code which acted on the detail band visible property probably was not
    going to give the result I wanted ... but I figured I should ask anyway in
    case there was a way to do it I did not know about.

    One question though:

    Why is it whenever I try to reference ppReport1 or ppDetailBand (or any
    other pp.... element) I get an Undeclared Identifier error in my code? The
    code I wrote below results in such an error, yet was copied from a similar
    function on the wiki.


  • edited February 2010
    Hi Steve,

    Are you using RAP? If so, you need to use the names defined in the object
    tree of the code workspace. In Delphi, the components are defined at the
    top of the interface section and those names should be used.

    As a side note, an easier way to access the detail band is by using the
    Report.DetailBand property.

    --
    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.