Ken Hamady, MS (7/21)
(888) 752-4916
21
Linked Subreports:
A subreport may contain a parameter field. If left unlinked, the subreport parameters will appear
with the container report parameters. The values you enter are passed to the subreport.
Alternately, Crystal allows you to link the subreport parameters to a field in the container. When
linked, the subreport parameter will not prompt you. Instead, it will take the current value of the
linked field, and use this value to fill in the subreport parameter.
You can link subreport parameter fields to any field in the main report. This includes database
fields, formula fields, totals or even parameter fields in the container report. But, the field you
are linking to has to have the same data type. For instance, you could link the start date
parameter in the subreport to a start date parameter in the container. This way you only have to
enter the date once, and it fills in both parameter fields.
Recurring Subreports:
Linked subreports can generate a separate subreport for each group in the container. For
instance, if your container has details that are grouped by customer, you might need a subreport
at the end of each customer that is specific to that customer. So, you can create a parameter in
the subreport for the Customer ID. You then add a rule in the select expert of the subreport that
says Customer ID / is equal to / {?parameter}. This causes the subreport to only print for one
Customer at a time, based on the parameter. You could then place this subreport in the Group
Footer of the container and link the subreport parameter to the Customer ID of the container.
Each time the container prints a Group Footer, the subreport will request a Customer ID from the
container, and uses that Customer ID to fill the subreport parameter. The subreport will only
include records that match that Customer ID.
Steps to add a linked Subreport:
Create a subreport that uses a parameter field.
Follow the first 2 steps above for adding an unlinked subreport.
Before you click “OK”, select the links tab at the top of the subreport window.
Select the linking field from the container and click “>” to move it to the right.
In the lower left select the subreport parameter field to link to.
Click “OK and place the subreport in the correct section of the container.
Letting Crystal Add a Link:
Optionally, if you are creating a simple select parameter, you can let Crystal add a parameter to
the subreport for you. When you are in the “Link” window and move over your link field,
Crystal will suggest a parameter name using the name of the link field with “?PM-” in front of it.
Crystal will add this parameter to the subreport unless you select another parameter.
If you are letting Crystal add the parameter, and you leave the check mark next to “Select data in
subreport...”, Crystal will also add a new rule in the selection formula of the subreport. This
new rule will say that a selected field in the subreport has to be “Equal to” the value of the new
parameter field. Crystal will let you pick the subreport field to use, showing you all of the fields
with the appropriate data type. Personally, I find it clearer to create my own parameters in the
subreport, give them meaningful names and determine how they are used, rather then letting
Crystal create them for me.