Linking Subreports to Your Main Report

When you create a report with a simple query the output is contolled by the query. prefix. So for example if we pull the firstname and lastname from the employee table we would output the emplyee name like this:

query.firstname query.lastname

It's a little different than standard ColdFusion because we don't really define a cfquery name="foo" and use the foo as the prefix. So the problem comes when you run subreports and try to use query.employeeID in the subreport to say pull payroll info from the payroll table:

Select t1.salary, t1.paydate
From payroll t1
Where t1.employeeID = #query.employeeID#

The frustration is that the failure is a bit ambiguous because the message will state that query.employeeID is undefined. The thing to remember is that items you are passing in from another query are param. prefixes. So this will work given you have assigned employeeId as an input variable in the properties box in the main report:

Select t1.salary, t1.paydate
From payroll t1
Where t1.employeeID = #param.employeeID#

Thanks Jim Bambrough for the help. His longer example is here: http://www.adobe.com/devnet/coldfusion/articles/subreport.html

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner