Symptom
In Crystal Reports (CR) 8.5 and earlier, how do you suppress a section in the main report that contains a blank subreport?
For example:
A subreport is placed in the group header of the main report.
If the subreport does not return data, the group header still contains a blank space the size of the subreport.
Resolution
To suppress a section in the main report that contains a blank subreport, the following procedures must be completed.
====================
NOTE:
" These instructions apply to Crystal Reports 6, 7, 8 and 8.5.
" New to Crystal Reports 9 is the 'Suppress Blank Subreport' check box. For more information on how to suppress blank subreports in CR 9, refer to our knowledge base article c2011893.
====================
· creating a duplicate subreport
· placement of a duplicate subreport
· creating a formula to test if the subreport is blank
· conditionally suppressing a section that contains original subreport
· minimizing a duplicate subreport and resizing the section
Crystal Reports 7, 8 and 8.5
------------------------------
To suppress a section that contains a blank subreport in CR 7, 8 and 8.5, complete the following:
Creating a Duplicate Subreport
------------------------------
You must create another subreport based on the original subreport. To create a duplicate subreport, complete the following steps:
1. From the main report in CR, right-click the subreport.
2. From the fly-out menu, select 'Save Subreport As'.
3. Provide a name for the duplicate subreport and click 'Save'.
Placement of a Duplicate Subreport
----------------------------------
Place the duplicate subreport into the section above the original subreport. For example, if the original subreport is contained in the group header of the main report, create another group header and place the duplicate subreport into it.
To insert a section into the report, complete the following steps:
1. In design mode, right-click the left gray margin where the subreport is located.
For example:
If the subreport is located in the group header, right-click the left gray margin at the group header level.
2. From the fly-out menu, select 'Insert Section Below'. You notice another section is inserted into the report labeled 'b'.
For example, by inserting another group header you notice that there is group header a and group header b.
3. Select the original subreport, drag and drop it into the second section.
4. Insert the duplicate subreport by selecting 'Subreport', from the 'Insert' menu.
5. Select 'Choose a report', from the 'Insert Subreport' dialog box.
6. Browse to find the duplicate subreport.
7. Select the report and click 'Open'.
8. Click 'OK'. The duplicate subreport will be attached to the cursor.
9. Insert the subreport in the new section (such as group header b from step 2).
10. In the main report, on the 'Edit' menu click 'Subreport Links'. The top drop-down box will contain both the original and duplicate subreports. Compare these two subreports and enure that the fields in the 'Filed(s) to link to' box are the same. Also, check that the parameter in the bottom-left drop-down box and the field in the bottom-right drop-down box are the same.
Creating A Formula To Test If The Subreport Is Blank
----------------------------------------------------
In the duplicate subreport, you must create a formula to test whether the contents of the subreport are blank. The results of this formula are going to be stored as a shared variable and shared with the main report.
To create this formula, complete the following steps:
1. Right-click on the duplicate subreport and from the fly-out menu, select 'Edit Subreport'.
2. From the 'Insert' menu, select ' select 'Field Object'. This launches the 'Field Explorer'.
3. Select 'Formula Fields' and select the 'New' icon.
4. Type a name into the 'Formula Name' box and click 'OK'. For example, CheckForNull. This launches the formula editor.
5. Create a formula similar to the following:
// @CheckForNull
Whileprintingrecords;
Shared BooleanVar Suppress;
If IsNull(Count({Table.field})) or Count(Table.field) = 0 then Suppress:= TRUE
Else Suppress:= FALSE
6. Place @CheckForNull in the Report Header of the duplicate subreport.
Conditionally Suppressing a Section Containing Original Subreport
-----------------------------------------------------------------
To conditionally suppress the section that contains the original subreport, complete the following steps:
1. From the 'Format' menu, select 'Section'. This launches the 'Section Expert'.
2. From the 'Section Expert' dialog box, select the section that contains the original subreport.
3. Click the 'X+2' button beside the 'Suppress (No drill down) check box. Ensure the checkbox is clear.
4. In the 'Format Formula Editor', create a formula similar to the following:
// The section will be suppressed if
// variable Suppress is True
Whileprintingrecords;
Shared BooleanVar Suppress = True
Now when you preview the report, you notice that the sections that contain a blank subreport are suppressed. However, the section that contains the duplicate subreport is visible on the main report. In order to suppress the section still visible you must minimize and resize the section.
Minimizing the Duplicate Subreport & Resizing the Section
---------------------------------------------------------
To minimizing the duplicate subreport on the main report and resize the section, complete the following steps:
1. From the main report, right-click the duplicate subreport.
2. From the fly-out menu, select 'Edit subreport'.
3. Suppress all of the sections in the duplicate report.
4. Select the main report.
5. Right-click the duplicate subreport, and from the fly-out menu, select 'Format Subreport'.
6. From the 'Format Editor', select the 'Border' tab.
7. From 'Line style', select 'None' for Left, Right, Top, Bottom.
8. Select the main report.
9. Resize the section that contains the duplicate subreport to be as small as possible.
Crystal Reports 6
-----------------
Before you begin this process, you will need to download uflstore.zip from our website at:
http://support.businessobjects.com/search
The reason you need to obtain this file is because shared variables were introduced in Crystal Reports 7. In order to suppress a section that contains a blank subreport in Crystal Reports 6, you will need to use the store and fetch function.
To suppress a section that contains a blank subreport in Crystal Reports 6, complete the following:
Creating a Duplicate Subreport
------------------------------
You must create another subreport based on the original subreport. To create a duplicate subreport, complete the following steps:
1. From the main report in CR, right-click the subreport.
2. From the fly-out menu, select 'Save Subreport As'.
3. Provide a name for the duplicate subreport and click 'Save'.
Placement of a Duplicate Subreport
----------------------------------
Place the duplicate subreport into the section above the original subreport. For example, if the original subreport is contained in the group header the main report, create another group header and place the duplicate subreport into it.
To insert a section into the report, complete the following steps:
1. In design mode, right-click the left gray margin where the subreport is located.
For example:
If the subreport is located in the group header, right-click the left gray margin at the group header level.
2. From the fly-out menu, select 'Insert Section Below'. You notice another section is inserted into the report labeled 'b'.
For example, by inserting another group header you notice that there is group header a and group header b.
3. Select the original subreport, drag and drop it into the second section.
4. Insert the duplicate subreport by selecting 'Subreport', from the 'Insert' menu.
5. Select 'Choose a report', from the 'Insert Subreport' dialog box.
6. Browse to find the duplicate subreport.
7. Select the report and click 'Open'.
8. Click 'OK'. The duplicate subreport will be attached to the cursor.
9. Insert the subreport in the new section (such as group header b from step 2).
10. In the main report, on the 'Edit' menu click 'Subreport Links'. The top drop-down box will contain both the original and duplicate subreports. Compare these two subreports and enure that the fields in the 'Filed(s) to link to' box are the same. Also, check that the parameter in the bottom-left drop-down box and the field in the bottom-right drop-down box are the same.
Creating a Formula to Test if the Subreport is Blank
----------------------------------------------------
In the duplicate subreport, you must create a formula to test whether the contents of the subreport are blank. The results of this formula are going to be stored as a shared variable and shared with the main report.
To create this formula, complete the following steps:
1. Right-click on the duplicate subreport and from the fly-out menu, select 'Edit Subreport'.
2. From the 'Insert' menu, select ' select 'Field Object'. This launches the 'Field Explorer'.
3. Select 'Formula Fields' and select the 'New' icon.
4. Type a name into the 'Formula Name' box and click 'OK'. For example, CheckForNull. This launches the formula editor.
5. Create a formula similar to the following:
// @CheckForNull
Whileprintingrecords;
If IsNull(Count(Table.field)) or Count(Table.field) = 0 then
StoreBooleanVar ("Suppress", True)
else StoreBooleanVar("Suppress", False)
6. Place @CheckForNull in the Report Header of the duplicate subreport.
Conditionally Suppressing a Section Containing Original Subreport
-----------------------------------------------------------------
To conditionally suppress the section that contains the original subreport, complete the following steps:
1. From the 'Format' menu, select 'Section'. This launches the 'Section Expert'.
2. From the 'Section Expert' dialog box, select the section that contains the original subreport.
3. Click the 'X+2' button beside the 'Suppress (No drill down) check box. Ensure the checkbox is clear.
4. In the 'Format Formula Editor', create a formula similar to the following:
// Conditional suppression on section containing original subreport
Whileprintingrecords;
FetchBooleanVar("Suppress") = True
Now when you preview the report, you notice that the sections that contain a blank subreport are suppressed. However, the section that contains the duplicate subreport is visible on the main report. In order to suppress the section still visible you must minimize and resize the section.
Minimizing the Duplicate Subreport & Resizing the Section
---------------------------------------------------------
To minimizing the duplicate subreport on the main report and resize the section, complete the following steps:
1. From the main report, right-click the duplicate subreport.
2. From the fly-out menu, select 'Edit subreport'.
3. Suppress all of the sections in the duplicate report.
4. Select the main report.
5. Right-click the duplicate subreport, and from the fly-out menu, select 'Format Subreport'.
6. From the 'Format Editor', select the 'Border' tab.
7. From 'Line style', select 'None' for Left, Right, Top, Bottom.
8. Select the main report.
9. Resize the section that contains the duplicate.
==========================
TIP:
To distinguish between the section containing the duplicate subreport and the section containing the original subreport, you can format one of the sections with a different background color.
To format a section with a background color, follow these steps:
1. Right click the section to select it and from the fly out menu select 'Format Section'.
2. In the 'Section Expert' select the section containing the duplicate subreport from the 'Sections' dialog box.
3. Click the 'Color' tab and select the 'Background Color' check box.
4. Select the desired color from the list.
==========================
Keywords
SUPPRESS BLANK SUBREPORT SUBREPORTS CONCEAL NULL FORMAT FAKE MOCK DUMMY C2000055 Seagate Crystal Reports Seagate Info Blank Subreports Conditional Suppression , c2005853