Solved

Conditionally suppressing a section containing a subreport using EvaluateAfter

Posted on 2008-06-19
9
1,488 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crystal suppressing if sub report empty 8 60
SQL Expression in Crystal Reports 19 50
cross tab report accumulative amount 9 45
Pull date to Group header 6 26
Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

15 Experts available now in Live!

Get 1:1 Help Now