ActiveReports Developer 7
Subreport Sample
See Also Support Forum
ActiveReports Developer 7 > ActiveReports Developer Guide > Samples and Walkthroughs > Samples > Section Report > Layout > Subreport Sample

Glossary Item Box

The SubReports sample demonstrates how SubReport control can be used to generate nested and hierarchical reports.


ShowSample Location

ShowVisual Basic.NET

<User Folder>\ComponentOne Samples\ActiveReports Developer 7\Section Reports\VB.NET\Layout\SubReport

ShowC#

<User Folder>\ComponentOne Samples\ActiveReports Developer 7\Section Reports\C#\Layout\SubReport

ShowRuntime Features

When you run this sample, the blank Viewer form appears, with the drop-down list of the sample reports on the top of the form. Select the report from the drop-down list to have it displayed in the Viewer control. You can select from the following options.

  • Simple SubReport - the basic sample report that demonstrates how to embed a report into another report. See rptSimpleMain and rptSimpleSub for details.
  • Nested SubReport - the report demonstrates how to nest subreports to display main, child, and grandchild levels in a report. See rptNestedParent, rptNestedChildMain and rptNestedChildSub for details.
  • Hierarchical SubReport - the main report dataset with the SHAPE statement defines the hierarchical structure of the report that uses a subreport. See rptHierarchicalMain and rptHierarchicalSub for details.
  • SubReport using the data set that contains relationship - the main report having dataset with the relation that is defined in code, in the DataSet.Relations property of the main rptDSRelationParent report. See rptDSRelationParent, rptDSRelationChildMain and rptDSRelationChildSub for details.
  • Master-detail report containing a SubReport - the sample report that demonstrates how to create a master detail report that uses a subreport. See rptMasterMain and rptMasterSub for details.
  • Bookmark in SubReport - the sample report that uses bookmarks from the subreport. See rptBookmarkMain and rptBookmarkSub for details.
  • Use a parameter in the SubReport - the sample report demonstrates how to set up a parameter in the data source of the subreport. See rptParamMain and rptParamSub for details.
  • To view the Dataset with multiple tables using SubReports - the sample report with the dataset that contains multiple data tables. The main report uses subreports to output multiple tables in a single report. See rptUnboundDSMain and rptUnboundDSSub for details.

    Note: To run this sample, you must have access to the Nwind.mdb. A copy is located at [User Documents folder]\ComponentOne Samples\ActiveReports Developer 7\Data\NWIND.mdb. If you are unable to access the data files in the sample, create the Data folder and place all the data files to this folder, or change the reference path to the data files within the folder according to your environment.

ShowProject Details

ShowViewerForm

The ViewerForm uses the ActiveReports Viewer control in the bottom section of the form, and a panel docked to the top with the drop-down list. The Viewer displays a report once it is selected from the list.

ShowrptBookmarkMain

This report is displayed when you select the Bookmark in SubReport option in the drop-down list of the ViewerForm.

This report uses bookmarks that you can see in the Document map of the Viewer sidebar, which is displayed if you click the Toggle sidebar button in the Viewer's toolbar. See Linking in Reports and Add Bookmarks for details on using bookmarks in ActiveReports Developer.

The report uses the PageHeader section to display the name of the report, the Detail section to display data and the PageFooter section to display the report information. The Detail section contains the Subreport control that displays data from rptBookmarkSub.

The report is bound to Nwind.mdb at runtime.

ShowrptBookmarkSub

This report contains the Product List information for the Subreport control in rptBookmarkMain.

This report also contains bookmarks, which are setup in code in the Detail Format event.

ShowrptDSRelationChildMain

This report displays the Product Name information and is the subreport for rptDSRelationParent.

The report uses the GroupHeader section to group data by Product Name and to display the label for the data in the Detail section, and the Detail section to display data. The Detail section contains the Subreport control that displays data from rptDSRelationChildSub.

The report is bound to the data row collection.

ShowrptDSRelationChildSub

This report displays the Order Details information and is the subreport for rptDSRelationChildMain.

ShowrptDSRelationParent

This report is displayed when you select the SubReport using the data set that contains relationship option in the drop-down list of the ViewerForm. This report demostrates how to bind a subreport to a dataset with a relation, defined in the DataSet.Relations property in code, and how to work with nested data relations.

The report uses the PageHeader section to display the name of the report, the groupHeader1 section to provide labels for the report data, the ghCategories to group data by Category Name, the Detail section to display data, and the PageFooter section to display the report information. The Detail section contains the Subreport control that displays the Product Name data from rptDSRelationChildMain.

The report is bound to the data row collection.

ShowrptHierarchicalMain

This report is displayed when you select the Hierarchical SubReport option in the drop-down list of the ViewerForm. 

The report uses the Detail section to display data and the PageFooter section to display the report information. The Detail section contains the Subreport control that displays data from rptHierarchicalSub.

The report is bound to Nwind.mdb at runtime.

ShowrptHierarchicalSub

This report displays the Order information and is the subreport for rptHierarchicalMain.

ShowrptMasterMain

This report is displayed when you select the Master-detail report containing a SubReport option in the drop-down list of the ViewerForm. This report displays orders with the general information, the order details in this report are taken from rptMasterSub.

The report uses the PageHeader section to display the name of the report, the Detail section to display data and the PageFooter section to display the report information. The Detail section contains the bound Textbox controls that display information for each order and the Subreport control that displays order details from rptMasterSub.

The report is bound to Nwind.mdb at runtime.

ShowrptMasterSub

This report displays the Order Details information and is the subreport for rptMasterMain.

ShowrptNestedChildMain

This report displays the Order Details information and is the subreport for rptNestedParent.

The report uses the groupHeader1 section to group the data by Orders ID, the groupHeader2 section to display static labels for the data in the Detail section, and the Detail section to display data. The groupHeader2 section contains the Subreport control that displays data from rptNestedChildSub.

The report is bound to Nwind.mdb at runtime.

ShowrptNestedChildSub

This report displays the Contact information and is the subreport for rptNestedChildMain.

The report is bound to Nwind.mdb at runtime.

ShowrptNestedParent

This report is displayed when you select the Nested SubReport option in the drop-down list of the ViewerForm. This report demonstrates how to set up embedded subreports to display main, child, and grandchild levels in a report.

The report uses the PageHeader section to display the name of the report, the groupHeader section to group the report data by Employee ID and to display static labels for the data in the Detail section, the Detail section that displays data on each employee, and the PageFooter section to display the report information. The Detail section contains the Subreport control that displays data from rptNestedChildMain.

The report is bound to Nwind.mdb at runtime.

ShowrptParamMain

This report is displayed when you select the Use a parameter in the SubReport option in the drop-down list of the ViewerForm. This report demonstrates how to set up a parameter in the subreport. See Parameters for more details.

The report uses the PageHeader section to display the name of the report, the groupHeader section to group data by Country and to display static labels for the report data, the Detail section to display Contact information, and the PageFooter section to display the report information. The Detail section contains the Subreport control that displays data from rptParamSub.

The report is bound to Nwind.mdb at runtime.

ShowrptParamSub

This report displays the Product Name information and is the subreport for rptParamMain.

The report is bound to Nwind.mdb at runtime.

The parameter is added to the sql query at runtime. Right-click rptParamSub in the Solution Explorer and select View Code to see the code implementation for the subreport parameter.

See Add Parameters in a Section Report for more details.

ShowrptSimpleMain

This report is displayed when you select the Simple SubReport option in the drop-down list of the ViewerForm.

The report uses the PageHeader section to display the name of the report, the Detail section and the PageFooter section to display the report information. The Detail section contains the bound Textbox control to display the Category Name information and the Subreport control to display data from rptSimpleSub.

The report is bound to Nwind.mdb at runtime.

ShowrptSimpleSub

This report displays the Product Name information and is the subreport for rptSimpleMain.

The Detail section contains the Barcode control.

ShowrptUnboundDSMain

This report is displayed when you select the To view the DataSet with multiple tables using SubReports option in the drop-down list of the ViewerForm.

The report uses the PageHeader section to display the name of the report, the Detail section and the PageFooter section to display the report information. The Detail section contains the bound Textbox controls to display Customer ID and Company Name, and the Subreport control to display data from rptUnboundDSSub.

The report is bound to the DataSet with multiple tables at runtime. Right-click rptUnboundDSMain in the Solution Explorer and select View Code to see the code implementation for the dataset connection.

ShowrptUnboundDSSub

This report displays the Order Detail information and is the subreport for rptUnboundDSMain.

The report uses the GroupHeader section to display static labels for Order List details in the Detail section.

See Also

©2014. ComponentOne, a division of GrapeCity. All rights reserved.