Using the ColdFusion Report Builder – Part 1: Creating Reports and Subreports
Linking a Report with an Existing Subreport
You can nest an existing report as a subreport inside another report. To do this, use the sample reports included in this tutorial named Department-Employees and Company-Departments. In this exercise, the Department-Employees report is the subreport.
This tutorial assumes that you have installed the sample applications with ColdFusion MX 7. You will be using the cfdocexamples data source, which points to the cfdocexamples database. If you have not installed the ColdFusion sample applications, run the ColdFusion installer again and select the option for installing the sample applications.
Once you have installed the sample applications, follow these steps to link the two existing reports:
- Copy Company-Departments.cfr report to a separate folder and rename it as Company-Departments_v1.cfr. Save a copy of the original report for the next exercise.
- Double-click the Company-Departments_v1.cfr report. This opens the ColdFusion Report Builder. If you have not installed the ColdFusion Report Builder, do so now.
- Expand the Detail band of the report to about 1.5 inches. You can do this by dragging the lower bounds of the Detail section or highlight the Detail section by clicking it and typing 1.5 as the Height property in the Property inspector.
- Click the Subreport component in the Toolbox (see Figure 1 again).
- Within the Detail band drag the cross hairs from upper left to lower right. You can resize this later as needed. The Subreport Wizard appears.
- Select the From an Existing Report option and click the ellipses to navigate to the Department-Employees.cfr report. Click Next.
- Because the sample subreport is already set up to take a parameter, the Subreport Wizard next asks you to bind the subreport parameters. For the DeptID, you can select from a pop-up list with the query's variables. Select
query.Dept_ID from the pop-up list and click Next.
- Click Finish.
- Resize the Subreport component to see all the fields that the query will return. The width should be approximately 6.5 inches.
At this point, your report looks similar to Figure 4.
Figure 4. Subreport made from an existing report
Save your report and preview it by pressing F12 or browse to the report. With a default ColdFusion installation, for example, it would be http://localhost:8500/subreports_example/ Company-Departments_v1.cfr.
Note: If you don't see a preview of your report when you press F12, select Edit > Preferences. Select Server Connection from the Preference Groups and modify the Server Information setting so that it points correctly to your ColdFusion server.