Subreports in Crystal Reports 2013- Tutorial
Subreports in Crystal Reports 2013: Video Lesson
This video lesson, titled “Creating Subreports,” shows you how to create subreports in Crystal Reports 2013. This video is from our complete Crystal Reports training, titled “Mastering Crystal Reports Made Easy v.2013-2011.”
Subreports in Crystal Reports 2013: Overview
Subreports in Crystal Reports 2013 are created in the same manner as normal reports, but are then embedded within a main report as a report object. Subreports in Crystal Reports 2013 also cannot contain another subreport within them. Subreports in Crystal Reports 2013 allow you to access and display information from two unrelated reports in a single report, or display multiple views of report data in a single report.
You can create either linked or unlinked subreports in Crystal Reports 2013. Unlinked subreports in Crystal Reports 2013 simply have no relationship between the records displayed in the subreport and the records displayed in the main report. The data is unrelated to each other in much the same way “unlinked” data in tables is unrelated.
In linked subreports in Crystal Reports 2013, the data in the subreport is matched to data in the primary report. For example, if you create an “Orders” report, you can create a linked subreport that displays the “Order Details” for each record in the “Orders” table. This could be used as another way of displaying the “one-to-many” type join between data in related tables.
To create subreports in Crystal Reports 2013, select “Insert| Subreport…” from the Menu Bar or click the “Insert Subreport” button in the Insert toolbar. This will invoke the “Insert Subreport” dialog box. In this dialog box, select how you want to create the subreport by using one of the two options displayed: “Choose an existing report” or “Create a subreport with the Report Wizard.”
If you select the first option, click the “Browse…” button to invoke the “Open” dialog box where you can choose which report you want to embed as a subreport within the main report. If you want to create the subreport “on-the-fly” within the primary report, instead choose the latter option button. Then click the “Report Wizard…” button to launch the Report Wizard dialog box, which steps you through the creation of a standard report.
You can also check the “On-demand subreport (similar to a hyperlink)” checkbox to create a subreport that does not display its data until the user double-clicks the subreport link. At that point, the users can drill-down to display the subreport data on a separate “Preview” tab. On-demand subreports in Crystal Reports 2013 are displayed within their own object frame in the main report, which reduces the amount of display space required within the main report. In addition, data from an “On-demand subreport” is not accessed from the database until the user double-clicks the subreport to display the detail data. You can later access the subreport object and change its caption using the “Format Editor.”
At this point, to create an unlinked subreport in Crystal Reports 2013, click the “OK” button and then click into the report at the place where you want to display the subreport data. Alternately, to create a linked subreport in Crystal Reports 2013, you must then click the “Link” tab in the “Insert Subreport” dialog box. When you create a link between the primary report and the subreport, they are linked together by a parameter field. The parameter field is used as a reference for the subreport’s record selection formula, which filters the records displayed.
Subreports in Crystal Reports 2013- Tutorial: A picture of the “Subreport Links” dialog box, which shows the links for a selected subreport in Crystal Reports 2013.
On the “Link” tab, use the “For subreport:” drop-down to choose which subreport to link to from the drop-down displayed. Then, in the “Container Report field(s) to link to” list, select the report field or underlying database field which will serve as the basis for the link between the data in the two reports. Click the “>” arrow button to move the selected field(s) into the “Field(s) to link to:” list at the right side of the dialog box.
At the bottom of the dialog box, use the drop-down at the left side of the dialog box to select the parameter field to use from the primary report. Select the associated field from the subreport to use for the link from the drop-down at the right side of the dialog box. After creating the association between the fields, click “OK” at the bottom of the dialog box. Then you can click into the position within the report at which you want to place the linked subreport.
Subreports in Crystal Reports 2013: Instructions
- To create subreports in Crystal Reports 2013, select “Insert| Subreport…” from the Menu Bar or click the “Insert Subreport” button in the Insert toolbar.
- Select how to create the subreport by choosing one of the two options shown in the “Insert Subreport” dialog box: “Choose an existing report” or “Create a subreport with the Report Wizard.”
- If you select the “Choose an existing report” option, click the “Browse…” button to invoke the “Open” dialog box and choose the report to embed as a subreport within the main report.
- To create the subreport “on-the-fly” within the primary report, instead choose the “Create a subreport with the Report Wizard” option button and then click the “Report Wizard…” button to launch the Report Wizard dialog box to step through the creation of a standard report.
- To create a subreport that does not display its data until the user double-clicks the subreport link, check the “On-demand subreport (similar to a hyperlink)” checkbox.
- To create an unlinked subreport, click the “OK” button and then click into the place in the report where you want to display the subreport data.
- To create a linked subreport instead, click the “Link” tab in the “Insert Subreport” dialog box.
- On the “Link” tab, use the “For subreport:” drop-down to choose the subreport to link.
- In the “Container Report field(s) to link to” list, select the report field or underlying database field which will serve as the basis for the link between the data in the two reports.
- Click the “>” arrow button to move the selected field(s) into the “Field(s) to link to:” list at the right side of the dialog box.
- At the bottom of the dialog box, use the drop-down at the left side of the dialog box to select the parameter field to use from the primary report.
- Select the associated field from the subreport to use for the link from the drop-down at the right side of the dialog box.
- After creating the association between the fields, click “OK” at the bottom of the dialog box.
- Click into the place within the report where you want to create the linked subreport.