Welcome!

You will be redirected in 30 seconds or close now.

ColdFusion Authors: Yakov Fain, Jeremy Geelan, Maureen O'Gara, Nancy Y. Nee, Tad Anderson

Related Topics: ColdFusion, Adobe Flex

ColdFusion: Article

CFDJ Feature: Creating Subreports with the Report Builder in ColdFusion MX 7

With ColdFusion MX 7, you can use subreports to show more detailed reporting

With 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:

  • Linking an existing subreport to a main report
  • Creating a new subreport ad hoc and linking it to the main report
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.

Requirements
ColdFusion MX 7.0.1
For a trial download: Trial Download To buy: To Buy

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.

ColdFusion Report Builder
ColdFusion Report Builder (EXE, 14.7 MB): www.macromedia.com/support/coldfusion/downloads_updates.html

Tutorials and Sample Files
http:download.macromedia.com/pub/developer/subreporting.zip

Prerequisite Knowledge
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 (www.macromedia.com/devnet/coldfusion/articles/reporting.html).

ColdFusion Reporting
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.

The Subreport Component
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 (see Figure 1). 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.

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.

Binding Subreports to Main Reports with Parameters
Generally, you can link a subreport to a main report by passing a value from the query in the main report as a parameter to the subreport; this value filters data in the subreport query. You can link the reports through the Subreport Parameters property of the subreport component. Find this property in the Data category of the subreport properties (see Figure 2).

This property corresponds to the input parameters of the subreport. The name of this property must match the name of the input parameter of the subreport. The Subreport Parameters property is an expression usually mapped to a field of the query in the main report (see Figure 3). You can view this property by clicking the ellipsis in the lower right corner in Figure 2.

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:

  1. 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.
  2. 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.
  3. 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.
  4. Click the Subreport component in the Toolbox (see Figure 1 again).
  5. 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.
  6. Select the From an Existing Report option and click the ellipses to navigate to the Department-Employees.cfr report. Click Next.
  7. 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.
  8. Click Finish.
  9. 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.

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.

Creating and Linking a New Subreport to Your Report
You can also create your subreport on the fly instead of linking to an existing subreport. In this section, follow these steps to create and link to a new subreport:

  1. Copy Company-Departments.cfr report to a separate folder and rename it as Company-Departments_v2.cfr. Save a copy of the original report so you can use it for other tests. Double-click the Company-Departments_v2.cfr report. This opens the ColdFusion Report Builder. If you have not installed the ColdFusion Report Builder, do so now.
  2. 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 Detail and type 1.5 as the Height property in the Property inspector.
  3. Click the Subreport component in the Toolbox (see Figure 1 again).
  4. 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.
  5. Select the As a New Report option and click Next.
  6. Click the Query Builder button to create a query to retrieve your recordset. The Query Builder window appears.
  7. Select your ColdFusion server for RDS.

    Note: If you have not set up an RDS server, you will need to do so now. To do so, refer to the ColdFusion LiveDocs Documentation. Expand the available data sources for your ColdFusion server, expand the cfdocexamples data source, and click Tables to expand the table choices. Double-click the Employee table. The Employee table appears in the top portion of the Query Builder.

More Stories By Jim Bambrough

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.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
SYS-CON Italy News Desk 01/19/06 03:10:43 PM EST

With Adobe 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.

SYS-CON India News Desk 01/19/06 02:44:52 PM EST

With Adobe 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.

@ThingsExpo Stories
In his keynote at 19th Cloud Expo, Sheng Liang, co-founder and CEO of Rancher Labs, discussed the technological advances and new business opportunities created by the rapid adoption of containers. With the success of Amazon Web Services (AWS) and various open source technologies used to build private clouds, cloud computing has become an essential component of IT strategy. However, users continue to face challenges in implementing clouds, as older technologies evolve and newer ones like Docker c...
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world.
JETRO showcased Japan Digital Transformation Pavilion at SYS-CON's 21st International Cloud Expo® at the Santa Clara Convention Center in Santa Clara, CA. The Japan External Trade Organization (JETRO) is a non-profit organization that provides business support services to companies expanding to Japan. With the support of JETRO's dedicated staff, clients can incorporate their business; receive visa, immigration, and HR support; find dedicated office space; identify local government subsidies; get...
Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
In past @ThingsExpo presentations, Joseph di Paolantonio has explored how various Internet of Things (IoT) and data management and analytics (DMA) solution spaces will come together as sensor analytics ecosystems. This year, in his session at @ThingsExpo, Joseph di Paolantonio from DataArchon, added the numerous Transportation areas, from autonomous vehicles to “Uber for containers.” While IoT data in any one area of Transportation will have a huge impact in that area, combining sensor analytic...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
Charles Araujo is an industry analyst, internationally recognized authority on the Digital Enterprise and author of The Quantum Age of IT: Why Everything You Know About IT is About to Change. As Principal Analyst with Intellyx, he writes, speaks and advises organizations on how to navigate through this time of disruption. He is also the founder of The Institute for Digital Transformation and a sought after keynote speaker. He has been a regular contributor to both InformationWeek and CIO Insight...
Michael Maximilien, better known as max or Dr. Max, is a computer scientist with IBM. At IBM Research Triangle Park, he was a principal engineer for the worldwide industry point-of-sale standard: JavaPOS. At IBM Research, some highlights include pioneering research on semantic Web services, mashups, and cloud computing, and platform-as-a-service. He joined the IBM Cloud Labs in 2014 and works closely with Pivotal Inc., to help make the Cloud Found the best PaaS.
It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
I think DevOps is now a rambunctious teenager - it's starting to get a mind of its own, wanting to get its own things but it still needs some adult supervision," explained Thomas Hooker, VP of marketing at CollabNet, in this SYS-CON.tv interview at DevOps Summit at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
DevOpsSummit New York 2018, colocated with CloudEXPO | DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City. Digital Transformation (DX) is a major focus with the introduction of DXWorldEXPO within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of bus...
Everything run by electricity will eventually be connected to the Internet. Get ahead of the Internet of Things revolution. In his session at @ThingsExpo, Akvelon expert and IoT industry leader Sergey Grebnov provided an educational dive into the world of managing your home, workplace and all the devices they contain with the power of machine-based AI and intelligent Bot services for a completely streamlined experience.
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
In his keynote at 19th Cloud Expo, Sheng Liang, co-founder and CEO of Rancher Labs, discussed the technological advances and new business opportunities created by the rapid adoption of containers. With the success of Amazon Web Services (AWS) and various open source technologies used to build private clouds, cloud computing has become an essential component of IT strategy. However, users continue to face challenges in implementing clouds, as older technologies evolve and newer ones like Docker c...
"Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...