Reports - Adding Unbound Detail Reports and Sub-Reports
- Adding Unbound Detail Reports and Sub-Reports
Adding Unbound Detail Reports and Sub-Reports
A Sub-Report embeds another report into the report, and an unbound detail report creates and runs another report not bound to the main report. So what does bound versus unbound mean? For bound, think of a book; the pages are bound together with a spine versus a stack of pages printed on a printer and attached with a paperclip, this is considered unbound. Regarding reports, a sub-report is placed in a band and runs throughout the report, while an unbound detail report may only print on a few pages and does not appear throughout the report.
Unbound Detail Reports
When adding an unbound detail report, a data source different from the main one may be used. Adding unbound detail reports can be extremely flexible when used with calculated fields and parameters (reporting options). It can solve most (if not all) of your reporting needs. However, the unbound detail report will run against each record in the main report, i.e., if the main report returns 100 records, the sub-report will run 100 times. We needed a dependable method to solve this issue where the main report would only return a single record. For this, we create a Data Profile containing the model's project information as this was the only reliable way to ensure the return of a single record. So if you decide to add an unbound report, set the Primary Data Profile to Project Information.
TIP: An exported configuration (.eVBatch file) of the Project Information Data Profile can be downloaded here, and report templates with the Primary Data Profile set to Project Information can be downloaded here.
The Subreport control is used to embed other reports into the current report. If there is a particular report structure (template) that needs to be included in many reports.
To add a SubReport control and script
IMPORTANT: Sub-Reports will not work until the below script is added.
- From the Report Designer, in the Tool Box, drag and drop the Sub-Report control to the desired band on the Design Surface.
- From the Scripts tab, add the below script:
private void SubReport_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
XRSubreport subreport = sender as XRSubreport;
if (subreport != null)
XtraReport report = subreport.ReportSource as XtraReport;
if (report != null)
report.DataSource = Report.DataSource;
- From the Design Surface, select the SubReport control, then from the Properties grid on the Behavior tab, expand Scripts, and set Before Print to SubReport_BeforePrint.
Defining the Sub-Report and parameter bindings
After the Sub-Report control is added to the report, the desired report file must be defined, then parameters in both the main report and sub-report must be bound.
- From the Design Surface, click the Sub-Report control and then click the Tasks button.
- From the Sub-Report Tasks pop-out window, define the Report Source URL; this is the location of the desired .repx file.
- From the Sub-Report Tasks pop-out window, click the Edit Parameter Binding link.
- From the Parameter Binding Collection Editor window, click the Add button.
- From the Misc grid, click the Binding menu and select the required parameter from the main report.
- From the Misc grid, click the Parameter Name menu and select the required parameter from the sub-report.
NOTE: the selected parameters must be the same data type with matching values.