Subreport Formatting with the Format Editor


There are a number of settings and features in the Format Editor you can use to further format and control subreport objects. On the main report Design or Preview tab, select the subreport object. Then, display the Format Editor by clicking the Format button in the Expert Tools toolbar, by choosing Format Format Subreport from the pull-down menus , or by right-clicking the subreport object and choosing Format Subreport from the pop-up menu. The Format Editor appears with the Common tab appearing.

Some items on the Common tab may be of particular use with subreports. For example, changing the object name for the subreport will make the Report Explorer more meaningful, as well as assisting you in Report Part navigation with web reporting (discussed in more detail in Part II of the book).

Tip  

If you are planning on passing values from a subreport to the main report (discussed later in the chapter), don t use the Suppress check box. Unlike a suppressed formula field (which will still calculate but won t display), a suppressed subreport does not process and will not generate values to pass to the main report. If you need to suppress a subreport from displaying, you will need to display the subreport Design tab and hide or suppress every section of the subreport. Then, returning to the main report, shrink the subreport object size as much as possible to reduce its height. The subreport will still run and pass values as if it were visible.

By default, the Can Grow option is checked whenever you create a subreport. This allows the subreport to grow vertically based on the actual data returned in the subreport. You ll typically want to leave this check box on for most subreports.

Formatting options particular to subreports appear on the Format Editor Subreports tab. While most of the options on the Subreport tab apply to on-demand subreports (discussed later in this chapter), three of the options bear further discussion here: Subreport Name, Re-import When Opening, and Suppress Blank Subreport.

click to expand

If you d like a more user -friendly name to display on the Preview and Design tabs for the subreport, or perhaps a better abbreviation, you can change the Subreport Name here. The change applies as soon as you close and re-display subreport related tabs, and it applies to both in-place and on-demand subreports.

The Re-import When Opening option is available only for subreports that were imported, rather than created, during the Insert Subreport dialog (this option will be dimmed if you format a subreport that you created from scratch). When you import an existing report as the subreport, Crystal Reports does not create a real-time link to the original .RPT file. The report design characteristics of the existing report are just added to the main report and then forgotten. If you later make changes to the original report that you imported, the changes won t be reflected here. However, Crystal Reports provides the ability to automatically or manually update (re-import) the subreport to reflect any changes to the original .RPT file.

To manually re-import a subreport that has had changes made to the original .RPT file, right-click the subreport object on the main report Design tab. Choose Re-import Subreport on the pop-up menu. The .RPT file that was used to originally import the subreport will be read again, and any changes will now be reflected in this report.

To have Crystal Reports automatically update imported subreports every time the main report is opened, format the subreport by selecting the subreport object in the main report Design tab or Preview tab. Then either use the Format menu or right-click the subreport object and choose Format Subreport, which will display the Format Editor. On the Subreport tab, check the Re-import when Opening check box. You may also set this option globally by choosing File Options and then checking the Re-import Subreports when Opening Reports option on the New Report tab.

Caution  

The automatic re-import option will cause problems if the original .RPT file is missing, if changes have been made to it for other purposes, or if the main report/subreports have been maintained with database changes but the original subreport .RPT file hasn t. And if you re-import a subreport, any changes you made to the originally imported subreport structure will be overwritten by the updated subreport. You won t be warned that your changes are going to be overwritten, and you cannot undo the import. If you realize that you ve overwritten subreport changes that you wanted to keep, close the report without saving it. Then, reopen the report.

The last option on the Subreport tab of the Format Editor is Suppress Blank Subreport. This option evaluates the subreport and suppresses its display entirely if it returns no records. However, note that the blank subreport object still takes up room in its main report section. Also, any values passed from the subreport to the main report in shared variables will not be updated (passing data from a subreport to the main report is discussed later in the chapter). The Handling Empty Subreports section later in this chapter describes steps to correct these display issues.




Crystal Reports 10
Crystal Reports 10: The Complete Reference
ISBN: B005DI80VA
EAN: N/A
Year: 2004
Pages: 223
Authors: George Peck

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net