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

Suppressed group header

edited March 2010 in Subreports
I have a subreport with 1 group (Group10). In the group header, I have
placed the data field the group is named on (employee department). The
details section contains string data (employee names). The group footer
contains a variable which counts the number of employee names (Variable18).
I'm trying to get the report to suppress the header/footer of any group
where Variable18 = 0. Variable18 is set to reset on Group10 end.

All of those items appear to be working correctly.

The header has a BeforePrint procedure:

procedure GroupHeaderBand10BeforePrint;
begin
if Variable18.Value = 0 Then GroupHeaderBand10.Visible := False ELSE
GroupHeaderBand10.Visible := True;
end;


The footer also has a BeforePrint procedure:

procedure GroupFooterBand10BeforePrint;
begin
if Variable18.Value = 0 Then GroupFooterBand10.Visible := False ELSE
GroupFooterBand10.Visible := True;

end;

For this report, I am getting 1 group where the result for Variable18 = 5.
The group footer displays correctly, but the group header is being
suppressed and I can't figure out why.

I am running this exact same subreport 9 times, only the variable names and
search criteria change, and the report headers show up correctly of all of
them except this one which happens to be the last subreport.

Any ideas?

Comments

  • edited March 2010
    Hi Steve,

    The issue is most likely that the variable has not made it's calculation
    before the GroupHeader.BeforePrint event fires. To work around this, you
    can set the variable to LookAhead and then set the visibility of the band
    during the second pass of the report.

    if (Report.SecondPass) then
    if (Variable18.Value = 0) Then
    GroupHeaderBand10.Visible := False
    ELSE
    GroupHeaderBand10.Visible := True;

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2010
    Good morning Nico,

    I tried your suggestion below and now the header band for every group is
    printing, even the ones which should be suppressed.

    I have also deleted and recreated the subreport from scratch. That did not
    fix the problem.

    I also took a subreport which was showing the headers correctly and modified
    it to show the data the broken subreport shows and doing that broke the
    header suppression on the working report.

    Finally, I modified the header formula to:


    procedure GroupHeaderBand10BeforePrint;
    begin
    if Trim(EMPLOYEES['DName']) = 'Lab' Then GroupHeaderBand10.Visible := True
    ELSE
    if Variable18.Value = 0 Then GroupHeaderBand10.Visible := False Else
    GroupHeaderBand10.Visible := True;
    end;

    This forces the missing department header to show, but it shows whether or
    not Variable18 = 0 now, so it makes the header show up where needed but also
    where not needed. It does seem to narrow the problem down to being an issue
    with when Variable18 is being evaluated.

    Thanks,
    Steve



  • edited March 2010
    Hi Steve,


    If you trace into the code accessing the variable value, what is it showing?
    The trick is to find the proper time to access this value. Is the variable
    resetting at the right time as well?

    --
    Regards,

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

    Best Regards,

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

    I'm afraid I don't know how to "trace into the code" to look for timing. I
    can see that my procedure for Variable18 is calculating the correct amount
    for the total when I preview the report, but I have no way that I can see to
    step through the processing to see what is happening and when.

    I've been thinking about this issue this morning. I have 9 essentially
    identical subreports. The headers are visible/not visible correctly in all
    cases except this. The only difference, as far as code, between my group
    total formula on this report and on the other 8 reports is that this one
    uses a nested pair of if-then statements to calculate rather than a single
    if-then statement.

    From the broken subreport:

    procedure Variable18OnCalc(var Value: Variant);
    begin
    if Copy(EMPLOYEES['NUMBER'],3,2) = '40' THEN
    begin
    if EMPLOYEES['CODE'] = 'PR192031' THEN Value := Value + 1 ELSE Value :=
    Value;
    end
    else Value := Value;

    end;


    From a working subreport:

    procedure Variable2OnCalc(var Value: Variant);
    begin
    if Copy(EMPLOYEES['NUMBER'],3,2) = '20' THEN Value := Value + 1 ELSE Value
    := Value;

    end;


    As far as code, that is the only difference between the reports. Does having
    a nested if-then change when the procedure is evaluated?

    Thanks
    Steve



  • edited March 2010
    Hi Steve,

    Are you using RAP? If so, I recommend moving the code (temporarily) to
    Delphi for debugging purposes. This way you can step through the event code
    and see exactly what is happening.

    If you would like, you can send me a minimal example that demonstrates the
    issue and I can take a look at it for you. Send all examples in .zip format
    to support@digital-metaphors.com.

    --
    Regards,

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

    Best Regards,

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

    Yes this is in RAP. I don't have Delphi. RB came bundled with our payroll
    application (hoping telling you that doesn't end my getting help on the
    newsgroups). The data is on a MS SQL Server 2005. Is there a way I can send
    the report along with sample data from that? I could copy the necessary
    tables from our test company SQL database to an Access database and send
    that, I suppose.


    Thanks,
    Steve


  • edited March 2010

    Please understand that Digital Metaphors can only provide tech support to
    the Delphi developers that purchase ReportBuilder. Digital Metaphors
    receives no distribution royalties from Delphi developers that embed
    end-user reporting solutions in their applications. It is the responsibility
    of the software publishers that sold you the product to provide you with
    tech support.

    There is an end-user tutorial called Learning ReportBuilder that can be
    downloaded from our web site for free. See the following article for more
    infomation.

    --------------------------------
    Article: Learning ReportBuilder
    --------------------------------

    Learning ReportBuilder is a complete learning system designed to teach end
    users how to build a range of reports. This system includes a 125-page PDF
    file, a stand-alone application complete with a database, and a help file.
    The PDF file is comprised of a series of tutorials that step end users
    through the process of building reports as simple as a table listing and as
    complex as crosstabs. The tutorials also introduce conceptual aspects of
    report building along the way. The application is used in conjunction with
    the tutorials so that the learning experience is interactive. The end user
    just prints out the PDF file, runs the application, and learns
    ReportBuilder. The help file is accessible from the application, so all
    three tools work together to provide a seamless learning environment.

    Learning ReportBuilder installs into C:\Program Files\LearnReportBuilder.
    When the system has successfully installed, a complete set of instructions
    appears in the form of a 'ReadMe' doc, so the end user knows just what to do
    upon installation.

    - Download Learning ReportBuilder

    http://www.digital-metaphors.com/LearnRB/LearnRB.exe


    --
    Tech Support mailto:support@digital-metaphors.com
    Digital Metaphors http://www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited March 2010
    > (hoping telling you that doesn't end my getting help on the newsgroups).

    you should try to get support from the people who supplied you the
    accounting software.

    FWIW, if DM supported all of the end users of their applications, just my 2
    licenses would have over 2,000 users for them--something their pricing model
    doesn't allow for.

    Ed Dressel
    Team DM
This discussion has been closed.