Solved

Conditionally suppressing a section containing a subreport using EvaluateAfter

Posted on 2008-06-19
9
1,484 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
  • 5
  • 4
9 Comments
 
LVL 100

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 100

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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 100

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 100

Accepted Solution

by:
mlmcc earned 500 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 100

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now