On-Demand Versus In-Place Subreports


By default, a subreport will process in-place as soon as Crystal Reports encounters it during main-report processing. Therefore, if you place a subreport in a group footer and preview the report, the subreport will process every time Crystal Reports comes to a group footer. If the report contains 75 groups and you click the last page-navigation button, 75 subreports will have to be processed before you see the page.

Depending on subreport size , database speed, or any of a number of other factors, this subreport processing may present a prohibitive performance problem. That s why Crystal Reports provides the on-demand subreport. An on-demand subreport simply exists as a placeholder on the main report, but it doesn t process as the main report progresses. Only when you click the subreport placeholder does the subreport actually process and appear in its own Preview tab.

There are two ways to denote a subreport as on-demand versus in-place. When you first create the subreport, check the On-Demand Subreport check box in the Insert Subreport dialog box. Or, you may change the settings for the subreport on the Subreport tab of the Format Editor. Check On-Demand Subreport to make the currently selected subreport on-demand. Now, when you preview the main report, only a placeholder outline will appear where the subreport would be. When the viewer clicks the placeholder, the on-demand subreport will process and appear in its own Preview tab.

Caution  

Since data is not saved in on-demand subreports, you may wish to avoid them if you distribute a report to a viewer who doesn t have access to the database. Even if a viewer opens a report with File Save Data with Report checked, on-demand subreports will have to connect to the database to be shown.

There are two helpful text options that make on-demand subreports more intuitive and interactive. The On-Demand Subreport Caption and Subreport Preview Tab Caption properties also exist on the Format Editor s Subreport tab. Both of these properties are set via Conditional Formula buttons , which allow you to create a conditional string formula that determines what appears inside the subreport placeholder in the main report and in the subreport Preview tab, respectively.

Since both are conditional formulas, you can use the complete Crystal Reports formula language to create a string formula to display. This gives you the flexibility to include actual database data in the formulas. For example, to prompt the user to click a subreport placeholder to see credit information for a particular state, you could enter the following formula for the On-Demand Subreport Caption:

 "Click to see Credit records for " + GroupName ({Customer.Region}) 

To show the state name in the Preview tab for the particular on-demand subreport that a viewer chooses, you could use the following conditional formula for the Subreport Preview Tab Caption:

 GroupName ({Customer.Region}) + " credits" 
Tip  

The Subreport Preview Tab Caption option is available with either on-demand or in-place subreports. If you double-click on an in-place subreport, it will appear in its own Preview tab with the caption formula displayed. The On-Demand Subreport Caption option is only available if you check On-Demand Subreport.

You can use other options on the Format Editor to choose the font face, size, and color; the border style; and the background color that appear on the placeholder. By using these formatting options creatively, you can make an on-demand subreport placeholder look clickable. Also, in the Preview tab of the main report, when you mouse-over an on-demand subreport, the cursor changes to the standard Windows hand, which denotes a clickable object.

Figure 13-4 (above) shows the resulting main report Preview tab. Notice that several subreports have been clicked and their Preview tabs have been customized.

click to expand
Figure 13-4: On-demand subreport
Caution  

If you are passing data back to the main report from a subreport (discussed later in the chapter), making the subreport on-demand will prevent the data from being passed back when the main report runs. Since the subreports aren t processing as the main report runs, there s nothing for them to pass back.




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