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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Configure Main Report to Not Display Based on Subreport

Status
Not open for further replies.

TheBig1980s

IS-IT--Management
Jun 11, 2007
60
In Crystal XI, I want to suppress sections of the main report when either of the two subreports that I have on my main report are blank.

Specifically, each of these two subreports does not always show data. That's because I have configured the one and only field in each subreport to suppress itself when that field is greater than or equal to 0.

In any case, if either of these two subreports are not displaying data, I do not want sections of the main report to display data. And, that's true if those sections contain either of these two subreports, any other subreports, or simply data from the main report.

How do I configure this?
 
I didn't realize until recently that this can actually be done.

1) Make both of these subreports into "Stealth" subreports, meaning they run but are completely invisible. Put their section above the main report section where they were. Here is an article that describes stealth subreports:


2) Use shared variables to transfer the values from the two subreports to two new formulas in the main report. Place these formulas where the subreport values used to appear.

3) Suppress the visible section if one or the other of these formulas is blank, zero or whatever.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides to Formulas, Parameters, Subreports, Cross-tabs, VB, Tips and Tricks
 
I appreciate the post, but I'm still not successful with this.

Are there any other ways of doing this. I just want to suppress the group header and group footer if the stupid subreports are blank.
 
Only way I know.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides to Formulas, Parameters, Subreports, Cross-tabs, VB, Tips and Tricks
 
TheBig1980s,

Instead of saying something doesn't work, you should explain in what way. Ken's solution should work, so you are probably missing one of the necessary steps.

Place the subreport in GH_a, with your regular GH fields in GH_b. Then suppress all sections WITHIN the subreport, format the subreport (in the main report->format subreport->subreport tab->check "suppress blank subreport"), remove the borders from the sub, and in the main report->section expert->check "suppress blank section". GH_a will no longer appear. Then create the shared variables in your subreport like:

whileprintingrecords;
shared numbervar amt := youramountsummaryorfield;

Then in the main report, you can display the amount in any section below the GH_a, by using:

whileprintingrecords;
shared numbervar amt;

...and/or you can suppress the sections by going into the section expert and using formulas like this:

whileprintingrecords;
shared numbervar amt;
amt >= 0

-LB
 
There are a whole myriad of issues. First of all, some records are still printing even though both subreports are showing "0". I don't want records that are greater than or equal to 0 to show--period.

Secondly, it is placing blank records for (I believe) data that is being suppressed. This is causing such issues as blank pages and other blank subreports to appear. I literally do not want any records to appear based on the criteria of these two subreports that we have discussed in this posting. This in essence creates a huge report. I just want records gone. I don't want blanks to appear in place of records that are no longer appearing....this is really hard to explain....sigh...that's why I don't usually explain why something is not working.

Thirdly, I have told the two new fields that you had me create to not show decimal places. I have done that by right-clicking the fields and placing "1" in that Number tab where you tell it how many decimals to appear. No dice. The fields are still printing two decimal places.

Also, when you say "remove the borders from the sub", how do you do that? Does that need to be done, anyway, if you are suppressing unneeded records anyway?

This is probably a lost cause. I wish Crystal just had a checkbox that you could check to do all of this. This is way too complicated.
 
OK....I figured out the decimal place business. But, the rest of the report still has issues per my earlier questions.
 
Not only that, I just saw that the report is printing duplicate and incorrect data on some records. This just flat out is not working.
 
So you rounded the values to get a true zero, correct?

Re: duplicate and incorrect date--you probably need a reset formula for your shared variables--you can put these in the group footer that corresponds to the group header where your sub is located:

whileprintingrecords;
shared numbervar amt := 0;

Then for blank records, make sure in the section expert that you have "suppress blank section" checked. Hard to tell what sections are actually blank but showing white space from your post.

-LB
 
Could the issue also be because I am doing two whileprintingrecord formulas in the main report's section expert? I just combined two formulas for the two subreports and separated them by semicolon.
 
This is what I meant in my last question by the syntax that I'm using in the main report's section expert:

whileprintingrecords;
shared numbervar suppress;
suppress >= 0;
whileprintingrecords;
shared numbervar suppress2;
suppress2 >= 0

Is that OK or do I need to rewrite?
 
I wouldn't use the variables. You have transferred the variables to formula fields that you can see on the main report. I would refer to the formula fields in your suppression formula.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides to Formulas, Parameters, Subreports, Cross-tabs, VB, Tips and Tricks
 
It is hard to troubleshoot without more information. I'm not sure what the remaining issue is. If you want to show us the content of your formula, you can, but I don't think this would account for extra white space. For more help, I'd want to know in what report sections the subs were located, what sections you want suppressed, the content of shared variable formalas and where they are located (reprot section, section expert) and an identification of the report sections that were appearing despite your sections to suppress them with no white space showing.

-LB
 
I will make one suggestion to help you troubleshoot:

Start over with the original report. Then do these steps:

1)Move the subreports to a new subsection above the section they are in now. Leave them visible for now.
2)Create the shared variable formulas to transfer the subreport values to the main report. Make sure that the values showing in the main report formulas match the subreports. No repeats or missing values.
3) Now make the 2 subreports into Stealth Subreports so the new section is invisible. Make sure the new formulas still show the correct values.
4) Now use the values you see in the main report to suppress the remaining section.

Tell us at which point the problems start.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides to Formulas, Parameters, Subreports, Cross-tabs, VB, Tips and Tricks
 
Thanks, to you both, for your help. I have combined both of your suggestions and have almost gotten this to work.

When I say "almost", there is one thing. Data for one of the two subreports does not appear. It's as if the report is choosing to suppress one of the two sets of data completely. Any thoughts?

In the section expert of group header 1b and group footer 1b where I have the shared variable fields, I have these two fields' syntax in the section expert as the following:

{Sales}>=0;
{Buy}>=0

Previously in this posting, I had called these two fields "Suppress" and "Suppress2" respectively. But, I renamed them in case the word suppress was already a defined funtion in Crystal.

Individually, I have tested the two subreports. They show data. It's just that the report is not showing data from one of the two subreports.

Should the two subreports or even the two shared variables be in different sections? The subreports are in group header 1a and, again, the two shared variables are in group header 1b.
 
After which of the 4 steps I outlined above does the problem first occur.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides to Formulas, Parameters, Subreports, Cross-tabs, VB, Tips and Tricks
 
Also, shouldn't you be suppressing this way:

{@Sales} = 0 or {@Buy}= 0

I thought you wanted to suppress if there was no data.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides to Formulas, Parameters, Subreports, Cross-tabs, VB, Tips and Tricks
 
No, I want the data suppressed if the fields are greater than or equal to 0. I apologize, if I did not make that clear.

It's hard for me to say at which of the four steps that the problem occurs. Both you and lbass are correct in the steps that need to be followed. And, I have almost gotten this to work based on all of the steps. I just don't understand why the report is only doing what I want for essentially one of the two subreports.
 
Hi Again:

I may have resolved this recent issue, just now. I took your syntax and made it "and" where I have it in Section Expert:

{@Sales} = 0 and {@Buy}= 0

Now, I'm finally seeing data from both subs. I just must have had the wrong syntax to begin with.

It will take me some time to go through it to see if the data is at last accurate. I will keep you both posted.

Thanks for your help, thus far!
 
If the data isn't appearing in one sub and they are in the same section, then I think the issue is your subreport linking. Check the links and also check how they appear in the record selection formula within the sub.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top