Click to See Complete Forum and Search --> : [RESOLVED] Supressing a section problem


Bill Crawley
November 24th, 2008, 08:11 AM
Hi All,

I'm using Crystal 11.

I have a sub report in a section. The subreport is made up of a Report Header and details section. The report header has Textual values and the detail section has data obtained from a DB.

From the main report if I go to section expert, and tick Supress Blank Section, The Report Header still appears from the sub report.

How can I tell the report NOT to print the Report Header if the Details are blank.

jggtz
November 24th, 2008, 01:57 PM
To suppress a section that contains a blank subreport:
------------------------------------------------------
Creating 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.

Bill Crawley
November 25th, 2008, 09:55 AM
Thanks for your very comprehensive answer.

I managed to do it with the following:

1. right mouse click the subreport whilst it is on the main report and select 'Format subreport'
2. select 'subreport tab'
3 Tick 'Suppress Blank subreport'.

I'm not sure what the difference is between this and right mouse clicking on the details section of the main report and selecting suppress sub report, but the above seems to work.

jggtz
November 25th, 2008, 12:31 PM
I'm sorry, the solution I posted was for lower versions (7, 8 and 8.5)