Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

8.03 More Section Formatting

Hiding and Suppressing Sections

Hiding a section is used for drilling-down on detail records. This presents the user with a much smaller report because the groups only show summary information. They can look at the detail information by double clicking on the group header. This creates a new tab in the viewer with the detail information being displayed inside.

Suppressing a section is similar to hiding a section, except that suppressing the section doesn’t let you drill-down into the data. Of course, this leads to the question that if you don’t want the user to see the information then why did you add the section? Suppressing sections is usually used in conjunction with conditional formatting. The Formula Workshop is used to turn this option on or off depending upon other data that the report has access to. For example, if this is sensitive data, then you would only let administrators see the detail information. All other users would have the detail section suppressed and they would only be able to see the summary information. This effectively lets you use the same report for different users and different purposes.

Printing Sections at the Bottom of a Page

Printing sections at the bottom of the page is useful when printing reports that are one page long and have summary data listed at the bottom. An example is an invoice where the bottom of the page prints the total amount due. Invoices also print the aging schedule of past due balances at the bottom of the page. Another example is a form letter that requires authorized signatures of certain parties. Printing sections at the bottom of the page is done by adding a group to the report and checking the Print at Bottom of Page option for the Group Footer.

Although the Details section has the Print at Bottom of Page option available, it has no effect. The detail records always print one after the other from top to bottom.

Forcing a Page Break

It is very common to want groups to appear by themselves. Data in each group is listed separately from the other groups. Forcing page breaks makes data from each group appear on their own pages. The group is used to identify where one report ends and the next one starts. An example is a report that has to be broken apart and distributed to multiple people.

Page breaks can be forced to occur either before or after a section. Unfortunately, each option has the problem of always printing an extra blank page. If you force a page break before a group header, then the first page of the report is blank. If you force a page break after the group footer, then the last page is blank. The way around this is to use one of two built-in functions in the conditional formula: OnFirstRecord or OnLastRecord. By doing a Boolean Not in the formula, it temporarily turns page breaks off for the section. For example, if you wanted to force a page break after the group footer, use the following formula in the New Page After format option:

Not OnLastRecord

This formula returns True for every record leading up to the last record. Thus, there is always a page break after the group footer. Once the last record is printed, this formula returns False and the option to force a page break is turned off. The last page will not have a page break printed after it.

Resetting the Page Number

Resetting a page number back to Page 1 makes the page appear as if it is the first page in the report. This is good to use in combination with forcing a page break after a section. For example, for the Group Footer, set the both of the properties New Page After and Reset Page Number After to True. When you distribute the pages of the report to different people, each person will have a report that starts on page 1. They won’t know that the pages they received were part of a much larger report that was broken apart.

Keeping Sections Together

Since it is common to print a lot of data in a section and since it is very hard to control exactly where a section is printed on a page, sections are commonly split across pages. A report can start printing a section at the bottom of the page but not have enough room to print all of it and print the remaining portion of the section on the next page. If it is important that all the information within a section be printed together, check the Keep Together option. Before the section is printed, it is analyzed to see whether it fits on the page. If it doesn’t fit, a page break is forced and the section starts printing at the top of the next page.

When using this formatting option with groups, the report tries to fit the entire group (including the header and footer) onto the page. If the group is larger than one page, a page break is forced and the group gets printed on the next page.

Suppressing Blank Sections

Printing sections that don’t have any data leaves blank rows in the report. This makes a report look unprofessional because of the gaps that seem to randomly occur. To fix this, set the option Suppress Blank Section to skip over sections that don’t have any data. This option is used most frequently in conjunction with creating multiple report sections. This is covered in more detail later in the book, “Adding Multiple Sections”.

Underlaying the Following Sections

When formatting a section so that it underlays the following sections, the following sections print on top of it. This has the effect of superimposing one or more sections on top of another section.

Underlaying sections is useful when working with images or charts and the related information is printed beside the image. This concept might be tough to grasp at first, so let’s look at two examples. Figure 8-3 shows an employee report with the employee’s picture on the left and the employee detail listed next to it. It doesn’t use the Underlay Following Sections option.



Figure 8-3. Employee Profile report with photo.

In Figure 8-3, the data listed next to the employee picture is from the Employee table. It shows the different fields from a single employee record. There is a one-to-one relationship between the employee photo and the employee data.

This example is limited in that the photo can only be printed next to the data within a single employee record. If you wanted to print a photo with multiple detail records next to it, this approach won’t work. The next example shows how to fix this problem by underlaying sections.

Figure 8-4 shows the design of an inventory report which lists how many products are on-hand for each inventory item. These items are grouped together by category and a generic picture of each category is displayed.



Figure 8-4. The Inventory report with pictures for each category.

To create this report, put the photo in the group header section and place it along the left edge of the section. Put the detail fields in the detail section and make sure that all the fields are to the right of the picture. Lastly, turn on the Underlay Following Section format option for the group header.



Figure 8-5. Inventory report using Underlay Following Section.

This causes all the group’s detail records to be printed on top of the group header. Since the image and the records aren’t on the same part of the page, this gives the effect of printing multiple detail records beside a single image.

Printing a Watermark

Using the underlay feature is useful when you want to print a watermark image on each page. Put the image in the page header and set the Underlay Following Section option on. Everything after the header is printed on top of the watermark image. Be sure to test the image to make certain it isn’t too dark. A faint image works best as a watermark because it allows the report text to be easily read.