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



There are no comments for this entry.
[Add Comment]