Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

9.05 Editing the Subreport

Editing the Subreport

Once the subreport object has been added to the main report, you will probably need to edit it. Depending upon the types of changes you want to make to the subreport, there are different ways of editing it.

To edit the content of the subreport, go to the main report and either double-click on the subreport object or right-click on it and select Edit Subreport. This opens the subreport in its own same design tab. The subreport is treated the same as any other report. You can add new report objects, modify existing ones, or delete report objects.

You can also modify other aspects of the subreport. When viewing the main report in design mode, right-click on the subreport object and there are two menu options called Format Subreport and Change Subreport Links. The Format Subreport menu item opens the standard format dialog box where you set properties such as Suppress, Keep Object Together, etc. The formatting options on the Border and Font tabs are for on-demand subreports. They control how they are displayed on the main report. This is discussed in the next section.

The Change Subreport Links item on the pop-up menu opens the Subreport Links dialog box. This lets you change the fields that are used to link the main report to the subreport.

You can’t put fields such as column headers in the Page Header of a subreport. Crystal Reports removed the Page Header section from subreports. Thus, you can put column headers in the Report Header section, but they will only print on the first page. To print column headers in a subreport requires tricking Crystal Reports into printing a fake report header. You create a dummy group and put the fields in the Group Header section. This imitates the Page Header section because you can have the Group Header print on every page.

To do this, create a new formula in the subreport using the following code:

WhileReadingRecords;
"";

Create a new group on this formula (it must be Group #1 so that it surrounds the rest of the report). In the new group header section, add the column headers or whatever report objects belong in the page header. Make sure it is set to print on every page. When you run the report, the group header will appear on every page of the subreport and it will look like it is a page header.