
With Macromedia ColdFusion MX 7, you can use subreports to show more detailed reporting. A subreport is simply a report embedded or nested inside another report. I refer to the report that contains the subreport as the main report from this point forward. The subreport and main report are typically related by the nature of their content.
In this article on ColdFusion reporting, you'll learn a couple of techniques for linking a subreport to a main report. The focus will be placed on linking subreports using the ColdFusion Report Builder.
This article covers several key concepts used for linking subreports to main reports, including how to bind reports with parameters. I discuss two techniques on how to link subreports:
Having had the daunting task of supporting reporting applications through Java applets (and I barely survived that one!), I have come to appreciate the simplicity and ease of development that comes with the new reporting paradigm. I hope that after reading this article, you will also appreciate the power and rapid development that is now available with ColdFusion reporting in ColdFusion MX 7.
Note: If you have already installed ColdFusion MX 7, please install the ColdFusion 7.0.1 updater. Also install the ColdFusion sample applications that come with ColdFusion. If you have not installed the sample applications, run the ColdFusion installer again and select Sample Applications during the installation process.
Recommended skills include a basic knowledge of ColdFusion and some reporting experience. However, this article will step through the sample subreport without assuming these skills. If you are new to ColdFusion reporting, please read Building Reports with ColdFusion MX 7 by Collin Tobin and Dean Harmon.
One common function of many companies is producing reports. There have been many software packages that offer these types of solutions, including Crystal Reports, Actuate, and Microsoft Access. Over time it has become more feasible and efficient to offer reporting through web applications. Previously, ColdFusion offered web reporting capabilities using the cfreport tag. With ColdFusion MX 7, however, developers have access to the new ColdFusion Report Builder to develop online reports.
The ColdFusion Report Builder tool is a separate software program included with ColdFusion MX 7 that integrates with your ColdFusion server for report development. When you use the ColdFusion Report Builder to create a report, it produces a separate file with a proprietary format, and extension of CFR. You refer to the filename in the template attribute of the cfreport tag. The cfreport tag has been available in ColdFusion for some time, but with ColdFusion MX 7 it has more functionality. You can configure the Report Builder to point to the web root of your ColdFusion server for report previews. You can easily configure your report as FlashPaper, PDF, or an Excel spreadsheet.
Typically, the ColdFusion Report Builder is used to design reports embedded in a ColdFusion page. The ColdFusion Report Builder interface is similar to that of Macromedia Flash Professional 8. There are a variety of components available in the ColdFusion Report Builder tool, including a label and a field component, each of which has its own set of properties. You can change these properties when you highlight a particular component or element of your report in the Property inspector. In this tutorial, you'll use a subreport component to link a main report to an existing subreport and link a main report to a new subreport.
Figure 1. Report Builder Toolbox with the Subreport component selected
You use the Subreport component to embed subreports in a main report. The next section describes how to bind the subreport to the main report using subreport parameters.
Jim Bambrough taught high school mathematics and computer programming in the Phoenix area for three years. Jim currently works as a web application developer for Amkor Technology in Chandler, Arizona. He has worked in IT since 2000 and has been developing web-based reports at the corporate level since 2003.