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

Suppress a subreport if result is empty 1

Status
Not open for further replies.

teamssc

Instructor
Nov 16, 2000
65
US
I'm new to this but if I understand correctly the following is saying create to a varible called "noprint" and if both fields return empty then suppress the detail.

whileprintingrecords;
shared BooleanVar noprint;
noprint:= isnull({?Manufacturer}) and
isnull ({?MfgPartNumber})then
noprint: = TRUE

I've inserted this into the detail, selection expert, supress blank section, x-2 button.


Now, if that was done correctly how do I write the corresponding forumla to insert in the main report detail section? I tried this but it doesn't suppress the detail in the main report.

whileprintingrecords;
shared booleanVar noprint;
TRUE

I'm also guessing I would insert the correct formula in the detail, selection expert, supress blank section, x-2 button.

Thanks!
 
I might be oversimplifying but I don't think this is as complicated as it seems. Simply right click the Details section of your subreport and select Section Expert. Then press the x-2 button next to Suppress and enter:

Code:
isnull({?Manufacturer}) and
isnull ({?MfgPartNumber}

This will suppress the details if those fields are NULL.

Now, right click the subreport in the main report and select Format Subreport and click on the Subreport tab. Check the 'Suppress Blank Subreport' checkbox.

This assumes you are using CR XI.
 
Thanks for your input but it is still not what I need.

The main report Detail has fields which populate
OrderNumber, Company, City, State

The subreport then brings up the corresponding Order Information based on matching the OrderNumber (this works correctly)

In the subreport I have the parameters you saw above.

My problem is that I'm still getting the main report detail data if the subreport is blank.
 
Almost got what I need by doing the following:

I created a Details B and moved the subreport to it. Now either your formula placed in the subreport, or my formula placed in the subreport section expert, and as you suggested "check the 'Suppress Blank Subreport' checkbox", work. I get the correct data and I get the subreport suppresed.

EXCEPT I lose the main report Detail fields which populate
OrderNumber, Company, City, State
 
Ok, so you're not trying to suppress an entire section, only certain fields?

If so, just format each field you want to suppress using your formula.
 
>>Ok, so you're not trying to suppress an entire section, only certain fields?
If so, just format each field you want to suppress using your formula.<<

No, It's working correctly and suppressing the subreport when the criteria is not met. My problem is that I'm now not getting the main report fields...
 
Your subreport must be in a section above the one you want to suppress, so if it is in a detail section, it should be in detail_a, with your main report details in detail_b.

Your main report section suppression formula for detail_b should be:

whileprintingrecords;
shared booleanVar noprint;
noprint = TRUE

You should also reset your shared variable in a suppressed detail_c:

whileprintingrecords;
shared booleanVar noprint := false;

-LB
 
lbass, If my subreport is moved to detail_a and my company fields are moved to detail_b then my data is out of order, unless I'm not understanding something...
 
lbass, what you suggested about moving the sub to detail_a and the main data to detail_b still formated data correctly and then I screwed something up trying to set something up ... so bear with me till I get back to that point.
 
You can format detail_a to "underlay following sections" if that helps.

-LB
 
lbass... let me step back through a few things because it's still not working correctly

1) whileprintingrecords;
shared BooleanVar noprint;
noprint:= isnull({?Manufacturer}) and
isnull ({?MfgPartNumber})then
noprint: = TRUE

Should the this still be used in the subreport? Which by the way I can't get it to accept as it says that "then noprint = TRUE" does not appear to be part of the formula.


2) Does that get placed via the section expert in the details section and do I place in by clicking on the x-2 button at Suppress Blank Section? Do I check Suppress Blank Section?
 
I think you should really be referencing the fields, not the parameters, as in:

whileprintingrecords;
shared BooleanVar noprint;
if isnull({table.manufacturer}) and
isnull ({table.MfgPartNumber}) then
noprint: = TRUE;

Then in the main report section expert, you should be going into "suppress"->x+2--NOT suppress blank section. You should have "suppress blank section" checked for detail_a and detail_b. You should also format the subreport (format ->subreport->subreport tab->check "suppress blank subreport". You should also remove the borders around the sub. Then when it is blank, detail_a will disappear, too.

-LB
 
Sorry for being so long getting back to this topic... it's the first day I've made it back to the job site.

LB, You're a life saver. I really think I only have a formatting issue at present. I'm getting alot of white space after the Group Header #2. I'm also getting white space after the Details_A & Details_B print out. The Report Header & Page Header & Group Header #1 and Group Header #2 are printing correctly, proper order with proper spacing. Suggestions?

BTW, just to recap what worked for me in case it helps anyone else...

In the Subreport, Details, I have ck'd Suppress Blank section then under x-2:
whileprintingrecords;
shared BooleanVar noprint;
if isnull({DocumentItems.Manufacturer}) and
isnull ({DocumentItems.MfgPartNumber}) then
noprint: = TRUE;

Close the subreport, then in the main report I have

Details_a, ck'd Suppress and under x-2 I have:
whileprintingrecords;
shared BooleanVar Noprint;
noprint=TRUE

I also have ck'd Suppress Blank Section, with nothing under the x-2

I also had to check detail_a to "underlay following sections". I did have to drop it down in the Details_a section an equal space of the Details_b or it would overprint Details_b.

Details_b, ck'd Suppress and under x-2 I have:
whileprintingrecords;
shared BooleanVar Noprint;
noprint=TRUE

I also have ck'd Suppress Blank Section, with nothing under the x-2

Details_c, Suppress (not Suppress Blank Section) and under x-2 I have:
whileprintingrecords;
shared BooleanVar noprint:= false;

Results: It's finally dropping the Details_b that don't have any data in the sub-report
 
If the sub is in detail_a, it should not be formatted to suppress or the shared variable will not pass. It should ONLY be formatted to "suppress blank section."

You need to check the gray area to the left of the report to see what section is causing the white space.

-LB
 
OK, Its Details_c.... I have it suppressed but had it open about 1/2" inch. That took care of it.

lbass, no crap, you have saved my life on this project. You are one of the most paitent people I know. I don't have a clue how to thank you enough.
 
If it is really suppressed, it doesn't matter how tall it is vertically. The reset formula you put in the section expert suppression x+2 formula area should instead be created in the field explorer->formula->new and then placed in the detail_c section and suppressed (field suppression->format field->suppress).

-LB
 
Ok, did it and I agree, now it doesn't matter how tall the details_c section is.

thanks
 
oops, missed this

GroupHeader#2 is printing out even if the details are completely empty. Suggestions?
 
You can't save the subreport results "up" to the group header, so you would have to add another copy of the subreport above the group header (b) and follow the earlier steps--same principles apply, only you would link at the group level to test for the presence of any fields.

-LB
 
amazing it would be that hard... but I'll go to work on it

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top