VSView Reporting Edition Reference > Field Object > Field Properties > Subreport Property |
Returns or sets a reference to another report to be rendered within the field (a Subreport).
field.Subreport[ = IVSReport ]
A subreport is a report that is inserted in another report. Subreports are useful when you want to combine several reports into one. For example, you may have a main report that integrates several subreports into a single main report. Or you can use the main report to show detailed information and use subreports to show summary data at the beginning of each group.
For some real-world examples, check the "Sales By Category" and "Sales By Year" reports in the NWIND.XML sample that ships with the control.
To define a field as a subreport, you should start by loading the subreport, then assign the subreport control to the field's Subreport property. For example:
Dim sSub = "Sales By Category Subreport"
vsrSub.Load "NWIND.XML", sSub
Set vsr.Fields(sSub).Subreport = vsrSub
Next, you should link the subreport to the main report using the subreport field's Text property (this is analogous to setting the LinkChildFields/LinkMasterFields properties in a Microsoft Access subreport). The Text property in a subreport field is used as a filter. It specifies which records in the source recordset should be used to render the subreport based on the current record for the main report. Continuing the example above, this would be done as follows:
vsr.Fields(sSub).Calculated = True
vsr.Fields(sSub).Text = "CategoryName = '" & [CategoryName] & "'"
When the main report is being rendered and reaches the subreport field, the above expression is evaluated and the result is a filter condition such as
CategoryName = 'Beverages'
This filter condition is applied to the subreport's source recordset, and when the subreport is rendered only the relevant records are listed.
Subreport fields usually have the CanGrow property set to True, so the subreport field can expand to include all its records.
IVSReport