Symptom
- Headers prints on one page, and the details on the next page.
- When printing or previewing a report in Crystal Reports, some Group Header displays at the bottom of the page and the group's records are displayed on the following page instead of on the same page as the Group Header. How to avoid this situation?
- How do you prevent an orphaned Group Header in Crystal Reports?
Environment
- SAP Crystal Reports 2013
- SAP Crystal Reports 2016
- SAP Crystal Reports 2020
Reproducing the Issue
-
In Crystal Reports, create a report off any data source.
- Add at least one field in the Details section of the report.
- Insert a group.
- Add in the Group Header section heading information.
- When viewing the report, it sometimes prints the header alone on one page, and displays it's details on the next page.
Resolution
- There are two ways to prevent an orphaned group header in Crystal Reports:
- Check the group option: "Keep Group Together"; or
- Add the header in the details section, and only print it the first time the group prints.
- Check the group option: "Keep Group Together"
When the option "Keep Group Together" is uncheck for a group, it prints each sections as space allowed on a page, and there is always the potential the Header prints on one page, and the related information starts printing on the next page.
When checking the options "Keep Group Together", it will keep the whole group together, therefore if there is not enough room on the page to print the group, it will start printing it on the next page, but note that there is always the potential to leave some white gap on the page, which is normal.
-
Open the report in Crystal Reports designer
-
Under the menu "Report", select "Group Expert..."
-
In the "Group Expert" window, select the "Group", and click the button "Options..."
-
In the "Change Group Options" window, under the tab "Options", uncheck the option "Keep Group Together"
-
Click "OK"
-
Perform the same steps if you have more than one group, then click "OK" to accept the change.
- Add the header in the details section, and only print it the first time the group prints.
The second suggestion is to combine the Group Header, with the Details section together, and only print what was in the Group Header the first time it prints group. In this way, the header will always print at the same time as the first details.
-
Suppress the Group Header, where the header are currently inserted.
-
Insert a new section in the Details section.
2.1 Under the menu "Report", select "Section Expert".
2.2 In the "Section Expert" window, select the "Details" section and click "Add"
It will create a "Details a" and "Details b" section. -
Set the new section to be be the first subsection of the Details.
-
Insert the Group Header information in the Details - a section
-
Create a formula that will use a variable to indicate when a new group starts printing, like:
WhilePrintingRecords;
BooleanVar PrintGroup := True -
Insert the formula in the suppressed Group Header section.
-
Create a conditional suppression on the Details a section, to only print it once per group. The formula will be like:
WhilePrintingRecords;
BooleanVar PrintGroup;If PrintGroup = True Then
(
PrintGroup := False;
False
)
Else
True -
Finally, in the "Section Expert", select the Details section, and ensure the following option is checked. "Keep Together"
( Do not select the Details - a, but select the root level, which is called: Details )
Now, the header for the group will print at the same time as the first details, since they are part of the same section.
Keywords
CR, GROUP KEEP TOGETHER, WIDOW, ORPHAN Group , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To