cancel
Showing results for 
Search instead for 
Did you mean: 

How to Suppress the Group when Sub-report is blank

Former Member
0 Kudos

All,

I need help with a problem i have with Crystal Report (2008 version). I have a main report with one sub-report.

Here are the details of Main report:

- Report Header (i have bunch of fields here)

- Page Header (Suppressed using Section Expert)

          - Page Header A (Suppressed using Section Expert)

          - Page Header B (Suppressed using Section Expert)

- Group Hearer 1 (Suppress Blank Selection using Section Expert)

- Group Header 2

         - Group Header 2A  (Suppress Blank Selection and Underlay Following Sections using Section Expert)

         - Group Header 2B (Suppress Blank Selection using Section Expert)

- Details (Suppressed using Section Expert)

- Group Footer 2 (Suppressed using Section Expert) 

- Group Footer (Suppressed using Section Expert) 

I have added following to the Main report:

- Column Labels are in GH1

- Sub-report is in GH2A

- 4 Fields are in GH2B 

The sub-report is the last column (i.e., right most column) in the report; the sub-report may or may not return a value.  If the sub-report does not return a value, i want the report to suppress all columns in the report. 

In my sub-report i have two columns/fields, i have all Sections except Details suppressed; the Details section is set to "Suppress Blank Selection". 

When i run the report, it will blind/suppress the sub-report column/cell if there is no data for the sub-report.  However, it will still show the 4 four columns.  How do i solve this issue.  Thanks

- Naveen

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Naveen,

You can create a running total also in Sub report and pass this to main report.

Create a manula running total using formula like this.

Whileprintingrecords;

Shared number x:=x+1;

Create another formula to assign x value

numbervar x;

shared numbervar a;

a :=x;

Then go to main report and write this condition whereever you want to suppress the sections when sub reports have no data

shared numbervar a;

if a  <> 0 then true else false

Make sure that you sub report should execute before the sections where you are using above formula.

If not then take a copy of sub report and place it above the section of the suppress formula you are using above.

Former Member
0 Kudos

Hi Vissu,

Thank you for the quick reply. I got a message when creating the first formula and therefore changed the formula to "Shared numberVar x:=x+1;

Note: I am using a Text field in the sub-report.

Then i proceeded with all remaining steps. However, i was not able to suppress the row.

I am not sure if Field Links between main report and Sub-report have to do anything with this problem. In the main report i have 5 tables; I created the Sub-report and then linked 8 fields from Two tables in the Main report to the 8 fields from one table that i use in my Sub-report. Is it possible that due to my report design, the sub-report will always be executed after the main report is executed. please let me know if you need any details.

Vissu and Jamie, I appreciate all your help.

Thanks,

- Naveen

Former Member
0 Kudos

Hi Naveen,

What error you are getting while creating running total.

Create like this.

WhileReadingRecords;

numbervar x :=x+1;

Then follow the steps I told above.

If your sub report is executing after the main report.

Then do like this.

Right click on your sub report which you added in main report->save sub report as and save it.

Then in main report ->insert sub report->choose the saved sub report and place it in report header of main report and make the sub report size as minimum as you can.

Then apply the suppress the condition for main report sections as I told in my earlier post.It will work I guess.

If not please send the screenshot of your report in design mode

JWiseman
Active Contributor
0 Kudos

hi Naveen,

this is a bit of work to do.

1) you need to do a Save As with your current subreport so that you have a copy of it.

2) insert a new section for Group 2 and move it to the top.

3) Insert a Subreport and choose the one that you saved in step 1 and put it in the new gh2 header.

4) in this subreport suppress all of the sections.

5) create a formula with a Shared Variable inside the new subreport

whileprintingrecords;

shared numbervar x:= Sum({choose one of your fields that will indicate whether there's no values})

6) in the main report create a new formula that will bring back the shared var and place this formula in a section below the new subreport

whileprintingrecords;

shared numbervar x

7) you can now use this shared var in your suppression formulas for the rest of the main report

😎 you can also go to the new section where the new subreport is and choose Suppress Blank Section

9) right click on the new subreport and choose Format > Subreport tab and then choose to suppress blank subreport

note that the reason for this method is to suppress sections or objects that are below the subreport. a shared variable cannot be used to suppress a section above the subreport or an object in a section above the subreport.

-jamie

Former Member
0 Kudos

Jamie,

Thank you for the quick response. I tried your solution, got a error on the way.

- When creating the Formula in step # 5, i got a message saying a number/currency was expected in the formula.  In the Sub report, i have a text field which may or may not have a value. Not sure how to proceed.

JWiseman
Active Contributor
0 Kudos

hi Naveen,

the step in 5 is only to establish whether or not the subeport is in fact empty. do you have any numeric fields available in the tables for the subreport to use in the Sum? the numeric field does not have to be displayed on the report.

for the subreport to be empty, you'll know that that the shared variable should be equal to 0. then later you use this 0 value to suppress the sections of the main report.

-jamie

abhilash_kumar
Active Contributor
0 Kudos

Hi Naveen,

You can change the formula in Step 5 from Jamie's suggestion to:

shared stringvar x := maximum({Text_Field})


Back in the Main Report, go to the Suppression formula for GH2A and use this code:

shared stringvar x;

len(x) = 0;


-Abhilash