Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Shared variables with subreports Post Reply Post New Topic
Author Message
kmailloux
Newbie
Newbie


Joined: 20 Jun 2012
Online Status: Offline
Posts: 2
Quote kmailloux Replybullet Topic: Shared variables with subreports
     Posted: 20 Jun 2012 at 3:48pm
I have a subreport which computes a total. It displays fine in my main report in a group footer. I need to use the total for a calculation so I created a variable to accept the shared value. That works fine if I place the main report variable below the line the subreport is on. I do not want to display/use the variable in a formula and DO  NOT want to see the subreport value. If I supress the subreport by variable goes to 0 (zero) for all records. If I place them both on the same line the variable value is off by one record. Any ideas?
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 21 Jun 2012 at 6:44am
There are a variety of tricks that can be done. One is to create another section to put the sub-report in and change the text to white and overlay the following sections.  Another way which Ken Hamady posted on his web site.
 "Shared Variables from a “suppressed” subreport
Wednesday 17 December 2008 @ 12:31 pm

A few years back I wrote about the Stealth Subreport. This is a subreport that doesn’t appear on the report but does run in the backround, providing shared variables to the main report. One of the limitations I listed at the time was the need to have a visible section that occurs at the same frequency as the subreport so that it can be hidden ‘behind’ something. In other words you couldn’t have a suppressed subreport at the detail level but have it still run and generate shared variables for use in the Group Footer or Report footer.

But I just learned that this limitation goes away with v9 of Crystal Reports. For versions 9 and later there is a method that allows you to truly have a suppressed subreport that is run invisibly in the background. It stems from a new feature introduced with version 9 called “Suppress blank Subreport”. Normally this used in combination with “Suppress blank Section” to hide a subreport that doesn’t find any data

What I didn’t realize till this month is that “blank” can also mean a subreport that has all of its sections hidden or suppressed. So even if there is data, as long as there is no visible output the subreport is considered blank and will be suppressed. I also didn’t realize that using these properties to suppress the subreport does not prevent the subreport from running. Normally suppressing a subreport means that it won’t run. But apparently these blank subreports are run before Crystal determines that they are blank, so there is time to actually store and capture their shared variables.

Thanks to Phyllis Swenson of CFI who pointed this method out to me."

Edited by kevlray - 21 Jun 2012 at 6:44am
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