Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Calcualtions Not Working When Supressed / Hidden Post Reply Post New Topic
Author Message
Jennie
Newbie
Newbie


Joined: 25 Jun 2009
Online Status: Offline
Posts: 3
Quote Jennie Replybullet Topic: Calcualtions Not Working When Supressed / Hidden
     Posted: 25 Jun 2009 at 3:12am
Hi, 
 
I have a report that calls a lot of info in in the details sections and then summarises etc in the group footer.
 
All the calculations work, the shared variables passing data from the subreport contain within the details section works - as does the manual summing of this data, all until I ask it to either hide or suppress the details section.  Cry
 
It is like there is some kind of optimisation going on that is not evaluating the details section unless it is actually printing them to screen.
 
When the details section is hidden / suppressed
the running totals / summaries work
anything to do with the shared variables from the subreport doesn't work unless shown on screen.
 
Has anyone come across this before, and knows a solution?
 
Also whilst I am at it does anyone know a way of getting the running totals / summary to work with a shared variable from a subreport? I am having to create manual summary fields.
 
Any help greatfully received
Thanks
Jennie
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 25 Jun 2009 at 6:12am
Takesen implied, and I think that he is right, that subreports don't run when they are suppressed.  I don't use subreport too often, and when I do, they aren't suppressed.  I am a big believer in bringing in as much data on one line as I can...usually every field that will print on the report, thus eliminating the need for a subreport.  Stored procedures allow me get the correct data.
 
I think suppressing the details section actually removes the call to the subreport, but I've been wrong before.
 
I don't think that shared variables and running totals mesh as the variables are not determined early enough, and that you will need to code all the summaries.  I always do, but then Running Totals confuse me ;).  DBlank uses running totals a lot and should be able to definitely state yes or no.
 
HTH
IP IP Logged
Jennie
Newbie
Newbie


Joined: 25 Jun 2009
Online Status: Offline
Posts: 3
Quote Jennie Replybullet Posted: 25 Jun 2009 at 6:32am
Hi,
 
I agree about the subreport, but becuase of the database structure the only way this info can be accessed is via a subreport :(
 
If anyone knows a way to make a subreport run when supressed (or just hidden) please let us know
 
Thanks
Jennie
IP IP Logged
AdamField
Groupie
Groupie


Joined: 04 Jun 2009
Online Status: Offline
Posts: 88
Quote AdamField Replybullet Posted: 25 Jun 2009 at 6:37am
Hey Jenni,
 
What i did here on a simular case was in stead of trying to find a solution for the problem i made a second detail section and i putted the subreport in that field, then i made that field VERY small and the text color on white so it wasn't visable in the output
 
this worked for me but i'm sure you can find a "better" solution as this work around.
 
Greets
 
Adam
IP IP Logged
Takesen
Senior Member
Senior Member


Joined: 29 Dec 2008
Location: United States
Online Status: Offline
Posts: 143
Quote Takesen Replybullet Posted: 25 Jun 2009 at 10:52am
Hey Jenni,

Adam's solution should work.
Basically what happens, is;

1. if a subreport is hidden/suppressed the shared variables wont pass the data. (thus the solution of just making it small and/or whiting out all the font)

2. If the sub report does not enter the main report BEFORE the calculations accure. The calculations don't work properly.

So, what i will usually do for situations like this, is if i know i'm going to need to do some calculations based off some subreports data (via shared vars)
I will put a copy of it in the report's Header. This way the sub report's data is processed as soon as you launch the report, and you can do any type of calculations at any point and time in the report. And then if there's data i actually want on the report itself shown from the sub report. I put a visible copy in the report.
IP IP Logged
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Posted: 26 Jun 2009 at 6:24am
I had this problem ages ago, and I asked in this very forum. I got the reply below from Brian, and it is so useful I have kept the text
----------
I have a couple thoughts, but it seems like you guys already tried them? First off, subreports are always calculated last in a section. So they will always return zero in the section they are printed in. No way around that. Now, Dreamcatcher said that he created a second footer section and put the subreport there. I'm assuming you put the subreport, and ONLY THE SUBREPORT, in Footer Section A? Always keep the subreport in its own section with nothing else in it. If you put it in section B then it will be called last and not work for you.

Now, if you did all that and it doesn't work (which is should work, but maybe something else is going wrong...) then you can put the subreport in the Detail section and suppress it. I wrote about how to do this in Tutorial 9-6  of my CR Encylopedia book.

1. After making sure that the subreport formula works (and you get tons of blank space), add it to ITS OWN SECTION (very important) in the main report.

2. Then go into the subreport and set EVERY section to be Suppressed. This disables printing the sections but the formulas will still be calculated. Test to make sure it is blank.

3. Then on the main report right-click on the subreport and select Format Subreport. Click on the Subreport tab and click the option Suppress Blank Subreport. This hides the subreport when every section is suppressed. Save your changes.

4. On the main report, right-click on the gray area to the left of the section that has the subreport and choose Section Expert. Click the option Suppress Blank Section. Save your changes. This will keep the subreport from printing, but its calculations are still run.

That should do it! I tested this pretty well prior to writing about it and it works like a charm.

IP IP Logged
Jennie
Newbie
Newbie


Joined: 25 Jun 2009
Online Status: Offline
Posts: 3
Quote Jennie Replybullet Posted: 29 Jun 2009 at 3:52am
Hi,
 
Thanks for the above - I have done all 4 steps and it works beautifully
 
Many thanks
Jennie
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum