Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group Selection based on Shared Variable from Subreport

Status
Not open for further replies.

xicana

Technical User
Dec 11, 2003
100
US
I have a report that has the following layout:

GH#1
GF#1A - SUBREPORT1
GF#1B - SUBREPORT2
GF#1C - SUBREPORT3
GF#1D - DISPLAYS SHARED VARIABLE TOTALS

In each report I have a shared variable which stores the total of a Running Total Field. The three shared variable have different names.

In Subreport1:
Code:
Whileprintingrecords;
shared numbervar SubRpt1SharedCount;
if isnull({#CountofDiags}) then SubRpt1SharedCount:= 0 else SubRpt1SharedCount :={#CountofDiags};

In subreport2:
Code:
Whileprintingrecords;
shared numbervar SubRpt2SharedCount;
if isnull({#CountofDiags}) then SubRpt2SharedCount:= 0 else SubRpt2SharedCount :={#CountofDiags};

In subreport3:
Code:
Whileprintingrecords;
shared numbervar SubRpt3SharedCount;
if isnull({#CountofDiags}) then SubRpt3SharedCount:= 0 else SubRpt3SharedCount :={#CountofDiags};
Within each subreport:
Each formula is placed in the group footer for the first grouping in that particular subreport. I reset the variable to zero at the group header of the first group in each subreport. If there is no data in the subreport, the shared variable stores a zero.

I am passing the value of the shared variable to the main report and placing it in GF#1D.

If the sum of all three shared variable is equal to zero...then I want to exclude the entire group from my main report.

I get the following message when attempting to do a group selection on the shared variables:

"The formula cannot be used because it must be evaluated later."

why is that, since the shared variables are being displayed on the main report in the very last group footer section?

Does someone have an idea on how to suppress, or group select based on the results of those shared variables?


Sandy
 
I think Crystal views the group as an entity, so you can't suppress the group on the basis of subreports within that group.

What you could do is show or suppress the group footer, assuming it comes after all of the subreports. Does that help?

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
No..I actually need the entire group to not show. See, I usually can use the group selection area to specify only showing those customers with more than $xxxxx.xx in A/P. The total $xxxxx.xx is calculated at the group footer of the customers ID...normally works fine...but since I'm passing a variable from subreport to main report, doesn't seem to want to let me do it.


Sandy
 
You could suppress the detail lines in the main report and show the same data as a subreport in the group footer, where the group footer qualifies. Inefficient but I can see no other way.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
The only way you can use the subreport to suppress the group the sub is in, is to add the subreport(s) again to a group header_a section (above the other subs) and then test the value of the shared variables from this in the section expert. You can suppress all the sections within each of these subs, format each sub to "suppress blanks subreport" on the format subreport screen, and then format GH_a to "suppress blank section" after removing the border from each sub. Then the subs in this section will not display at all, while still passing the shared variables for the group suppression.

-LB
 
Thanks for those ideas - I had thought about putting the lines in a group footer... but that and putting the subreport in the header as well as in the footer would make this report run for a really LONG (like hours) time...we're looking at 8500+ customers...each with 3 subreports to run...I figured the solution would probably make the report crash (or my computer) crash so I ended up dumping the data into access from each subreport...and then reporting that way...the report loaded a lot quicker and I was able to reach my objective (i had to submit by Thursday evening).

thanks for the tips.

Sandy
 
If you're able to use SQL Commands (Stored Procedures) then that would be a better long-term solution. You can selectively delete records that don't meet the criteria and use the Crystal as a 'front end' to show the results.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
I'm actually going to request some SQL training so that I may create my own stored procedures...I already create custom views to help me out...but need a little more education on Stored Procedures.

Thank you for your suggestion - one more reason to push the company into getting me that training!

Sandy
 
Fine. Make sure you get the right training - no need to learn how to create SQL databases from scratch, unless that's also part of your job.



[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top