Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

6.11 Multiple Sections

Adding Multiple Sections

Throughout this book, when different parts of a report were discussed, they were referred to by their section name. For example, when adding an object displayed in the header of a group, the portion of the report would be called the Group Header section. However, reports also have Areas. By default, when you create a new report each area is composed of a single section, and every section is only in one area. In fact, an area the container for a section. This gives you a one to one relationship between areas and sections. Thus, there is an area for the Report Header, Page Header, Details section, etc.

Crystal Reports lets you create dynamic reports by letting you add multiple sections to an area and format each section differently. This changes the relationship between Areas and Section to a one-to-many relationship. One area can have multiple sections within it. All sections can be displayed or formulas can be used to determine which section to show and which ones to suppress.

An area can have more sections added to it, but the sections must be of the same type. For example, the Details area can have two Detail sections in it, but it can’t have a Group Footer section in it.

An example of multiple sections is shown in Figure 6-10.



Figure 6-10. Multiple detail sections.

In this example, there are two sections between the group header and footer: Details a and Details b. Each section is part of the Details area. The benefit of having two sections within the same area is that it gives you a lot of flexibility for formatting the report. Creative use of multiple sections solves many reporting problems.

You first have to understand a couple of rules for working with multiple sections. The first rule is that multiple sections are printed consecutively. The first section (labeled with the ‘a’) is printed first. The ‘b’ section is printed second, and so on. The second rule is that you can change the formatting of any section and it doesn’t effect the formatting of the other sections. A section can be suppressed or have its background color changed and this has no effect on the other sections within that area.

Multiple sections can be inserted, deleted and merged with other sections. When you right-click on a section header, you get the menu shown in Figure 6-11.



Figure 6-11. Mulitple section menu.

When selecting Insert Section Below, it inserts a new section below the section that was clicked on. Select Merge Section Below to combine the current section with the one below it. Crystal Reports merges the two by taking all the objects in the lowest section and copying them to the section above it. All the new objects go underneath the existing objects. Select Delete Section to delete a section from the report.

If a section has too much white space underneath the report objects, make the space tighter by placing your cursor at the top of the section below it and dragging it higher. An easier, and more accurate, way of doing this is to select the Fit Section menu option. Crystal Reports adjusts the section height to fit the exact space needed for the report objects. No extra space is allocated.

Selecting Move Section brings up the Section Expert again. This dialog box displays all the report sections on the left-hand side. Now that you have multiple sections, the tabs along the top are no longer disabled. The dialog box with multiple sections is displayed in Figure 6-12. Use the arrow keys shown at the top to move the sections up or down.



Figure 6-12. The Section Expert for multiple sections.

When looking at the menu options along the top of this dialog box, you see that it also has the options to Insert, Delete and Merge sections. If you are working in the designer, you can also go to this dialog box by right-clicking on a section header and selecting Format Section.

The key to making multiple sections work is to use formatting in combination with formulas. Although formulas are discussed in complete detail in Chapter 7, it is easy to understand the basic concepts before reading that chapter. Formulas are used to turn formatting options on and off using built-in functions with other data in the report. The best way to understand this is to see examples. Here are some common uses of formulas with multiple sections that you can start using right away.