Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

9.16 More Unlinked Examples

Unlinked with a Formula

Formulas are used with unlinked subreports so that information can be passed to the subreport without filtering any data. The benefit of using a formula is that although the subreport isn’t linked, you can still pass information from the main report to the subreport. This information can be displayed on the report or used in the subreport’s formulas.

To create an unlinked formula field, go to the Link tab and select the formula from the main report’s list of available fields. Once the formula has been selected, the frame at the bottom of the dialog box appears and the parameter name is already filled in. Since this is an unlinked report, click on the checkbox labeled, “Select data in subreport based on field”, to deselect it. This causes the linking field dropdown box to become disabled and no linking field will be specified. The parameter field in the bottom left corner of the dialog box still gets created, but it doesn’t get linked to a specific field in the subreport.

When the subreport runs, it can reference the parameter that is created by this dialog box to get the formula’s value from the main report.

Unlinked with Shared Variables

Shared variables can be used to pass data between the main report and the subreport. This lets you perform calculations, track subtotals and create strings in one report and pass this data to the other report. The difference between using a parameter field and a shared variable is that shared variables can be used to pass data in both directions. When using parameter fields, data can only be passed from the main report to the subreport.

Since the subreport is not linked to the main report and no formulas are being passed to the subreport, then you shouldn’t set any properties on the Link tab. The difference is that both reports have to have a formula that declares and uses the shared variable.