The hypothetical COO scenario just explored highlights an example of an unlinked Subreport. In Crystal Reports terminology, this means that the parent, or main, report did not have any specific data connections (or links) to its related child report (the Subreport). Unlinked Subreports are completely independent from their main reports and do not rely on the main report for any data. Many reporting problems in which multiple views of the same or different data sources are required in a single presentation can be resolved with unlinked Subreports. If a requirement exists to share data between the parent/main report and its Subreport, linked reports provide the answer. Contrary to unlinked Subreports, linked Subreports are bound (or linked) to the data in their associated main report. The links are defined in the second tab of the Insert Subreport dialog as highlighted in Figure 16.4. Figure 16.4. Link tab of the Insert Subreport dialog.The Link tab enables the linking of report, database, or formula fields in the main report to fields in the Subreport and enables filtering of the Subreport based on the data passed in from the main report. The Available Fields section of the Links dialog enables the selection of the field from the main report to be linked on. More than one field can be selected for linking. After at least one field has been selected, a separate Field Links section will appear at the bottom of the Links tab. For each linked field, a parameter in the involved Subreport must be selected to receive and hold that information. These parameters can be existing parameters predefined in the Subreport, or they can be a parameter that is automatically created for each field you have selected to link. (These will be automatically created in the Subreport with the prefix '?Pm-'.) Finally, for each linked field from the main report, a data filter can be created in the Subreport based on that parameter. This is accomplished by checking the Select Data in Subreport Based on Field check box and selecting the report field, database field, or formula field in the Subreport that you want to have filtered based on the linked parameter from the provided drop-down box. In effect, checking this box will create a selection filter in your Subreport that is based on the selected filter field and the selected parameter field.
To explore a reporting solution with linked Subreports, let's solve the hypothetical reporting problem faced by the same COO of Maple Leaf Bikes Corporation. The COO now wants a single report that highlights the company's top-selling products in one bar chart (as before), but now wants a list of suppliers for those top-selling products to be available for review essentially, a Subreport linked to the main report based on the Supplier ID of the top-selling products. To accomplish this, follow these steps:
The COO can now make an informed analysis on whether his firm has too much reliance on a small number of suppliers or not, and you have learned some of the benefits of a linked Subreport.
|