Solved

Conditionally suppressing a section containing a subreport using EvaluateAfter

Posted on 2008-06-19
9
1,498 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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 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 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

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…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

636 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