Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Conditionally suppressing a section containing a subreport using EvaluateAfter

Posted on 2008-06-19
9
Medium Priority
?
1,506 Views
Last Modified: 2012-06-21
Hello experts,

I have a subreport that is set to suppress if blank.  The subreport is in section 1ca, which is also set to suppress if blank.  Even when the subreport is blank, though, section 1ca isn't suppressing - instead, the section displays a blank space that's the same length as the subreport design.  This is resulting in multiple blank pages in my report.

So I decided to do set up a shared variable to suppress section 1ca conditionally.  

In my main report, in section 1bz (above the subreport), I placed a formula field, NumDisplayedFieldsReset:

       Shared NumberVar NumDisplayedFields:= 0

The subreport consists of 60+ sections that each contain one field value.  Each section is suppressed if its field value is null.  I added a formula to each section that looks like this:

        Shared NumberVar NumDisplayedFields;

        If (the field value is not null) Then
             Shared NumberVar NumDisplayedFields := NumDisplayedFields
         Else  
             Shared NumberVar NumDisplayedFields := NumDisplayedFields + 1 ;

        NumDisplayedFields

In the main report, I set the suppression formula on section 1ca to this:

        Shared NumberVar NumDisplayedFields;
        NumDisplayedFields = 0

This didn't work.  I tested it by creating a new formula field called TotalDisplayedFields that retrieves and displays the NumDisplayedFields variable.  When I put TotalDisplayedFields in section 1cb (below the subreport), NumDisplayedFields = 13, as expected.  When I put it in section 1ca with the subreport, NumDisplayedFields = 0.

So I figured that the suppression formula for the section was being evaluated before the subreport was run.  I tried putting TotalDisplayedFields back in section 1cb, where it was equal to 13.  Then I changed the suppression formula on section 1ca to this:

       EvaluateAfter({@TotalDisplayedFields});
       {@TotalDisplayedFields} = 0

This didn't work - now the TotalDisplayedFields formula in section 1cb (AFTER the subreport) is displaying as 0!  When I remove the EvaluateAfter statement, then the formula calculates correctly as 13.  Just to see if I could figure out what was happening, I tried creating another new formula, TotalDisplayedFields2, that looks like this:

       EvaluateAfter({@TotalDisplayedFields});
       {@TotalDisplayedFields}

If I put TotalDisplayedFields2 in or before section 1ca, TotalDisplayedFields = 0.  If I put TotalDisplayedFields2 after section 1ca (including page headers that appear after section 1ca is printed and sections that I've inserted between section 1ca and the section containing TotalDisplayedFields), then TotalDisplayedFields = 13.

I'm at a loss here.   Is there any way for me to get this to work, or am I stuck with a bunch of blank pages on my report?

Thanks for any ideas, help or direction you can give me!
Anne
0
Comment
Question by:cummina
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 21824788
Try this

CHange the reset formula.  I have found that the declration works the first time in but once declared the reset needs to be on another line

Shared NumberVar NumDisplayedFields;
NumDisplayedFields:= 0;

mlmcc
0
 
LVL 1

Author Comment

by:cummina
ID: 21825386
I appreciate the reply, mlmcc, but unfortunately that didn't do it.  For this particular report that variable is only ever going to be set once anyway.

But it's a good tip - I'll keep this in mind for when I'm doing other resets!

Thanks-
Anne
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 21825837
Try doing the counting in  the suppression formulas rather than separate formulas

Also I think the counting formula is reversed.

mlmcc
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 1

Author Comment

by:cummina
ID: 21826033
No luck.  The suppression formula in the main report still seems to be evaluating before the subreport counts, regardless of whether I'm doing the counting in the subreport suppression formulas or in formula fields placed in the subreport sections.  I don't understand why the EvaluateAfter() function is so wonky - I really thought that would be my solution to this.

Also: Oops, sorry, yes, I did get the counting formulas backwards in my post, but they're fine in the report itself - the counting formulas are actually

        Shared NumberVar NumDisplayedFields;

        If (the field value is null) Then
             Shared NumberVar NumDisplayedFields := NumDisplayedFields
         Else  
             Shared NumberVar NumDisplayedFields := NumDisplayedFields + 1 ;

        NumDisplayedFields

Thanks-
Anne
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 21826295
Try it as

       Shared NumberVar NumDisplayedFields;

        If (the field value is null) Then
             Shared NumberVar NumDisplayedFields := NumDisplayedFields
         Else  
             Shared NumberVar NumDisplayedFields := NumDisplayedFields + 1 ;

         ''

mlmcc
0
 
LVL 1

Author Comment

by:cummina
ID: 21826459
Sorry, that didn't work either.

Just curious - what's your reasoning for working on the counting formulas in the subreport?  They work fine and I can pass the shared variable back to the main report.  I just can't seem to get the section suppression formula in the main report to evaluate based on the shared variable after it's passed back from the subreport.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 21827980
I was thinking maybe there was somethin in the subreport that made it seem to not be blank.

JUst tried to do what you are doing in a simple (blank) report.

I added a formula to the report header
WhilePrintingRecords;
Shared NumberVar ShowSection := 0;

In the subreport I added a formula to the report header
WhilePrintingRecords;
Shared NumberVar ShowSection;
ShowSection := 1

The subbreport was in the detail section.  I suppressed the detail section with
WhilePrintingRecords;
Shared NumberVar ShowSection;
ShowSection = 1

It didn't suppress.  I changed the formulas
To use a boolean rather than a number
Same result.

Crystal provides a document on the multiple pass method used to render a report.  In my reading of it, it seems what you are trying to do is no possible.  The subreport is evaluated after the formatting is done.
http://support.businessobjects.com/communityCS/TechnicalPapers/cr9_evaluationtimes.pdf.asp

mlmcc
0
 
LVL 1

Author Comment

by:cummina
ID: 21830395
Dang, I was afraid of that.  

I was hoping that EvaluateAfter would force the suppression formula in the main report to evaluate after the subreport was done, and that my problem with EvaluateAfter was something that someone would magically know how to fix.

Thanks for the effort, mlmcc.  I do appreciate it.  At least I've confirmed that it's not just me.

Anne
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 21836367
Sorry it turned out that way.  I thought I had a resolution but I had a bad formula that made it seem like it was working.

EvaluateAfter only works with formulas in the same report not with a subreport.

mlmcc
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question