from Crystal, orginally written in CR7:
First you need to link the subreport's stored procedure parameter to a
main report database field, then create a parameter in the main report and
finally compare the value(s) for this parameter against the main report
database field in a record selection formula.
1. In the main report, insert a subreport that is based on the stored
procedure:
· On the 'Insert' menu, click 'Subreport'. This opens the 'Insert
Subreport' dialog box.
· Click 'Create a subreport' and type a name for this subreport.
· Click 'Report Expert'. This opens the Subreport Expert dialog box, where
you specify the datasource, fields, and so on to include in the subreport.
· Once you've gone through the necessary tabs for your subreport, click
'OK'. This brings you back to the Insert Subreport dialog box.
2. Link the subreport to the main report.
· While still in the Insert Subreport dialog box, click the 'Link' tab.
· In the 'Container Fields' box, click the main report field that on which
you want to link the subreport.
· Click the '>>' button to add the field to the 'Fields to Link to' box.
· In the 'Subreport parameter field to use:' box, select the stored
procedure parameter.
· Click 'OK'. This brings you back to the report.
3. Create a parameter field in the main report:
· On the 'Insert' menu, click 'Parameter Field'.
· Click 'New'. This opens the Create Parameter Field dialog box.
· Type a name (let's call it Main Parameter) and prompting text for the
parameter.
· In the 'Data type' box, select the same data type as the main report
linking field from step 2.
· Click 'OK' to return to the report.
4. Create a record selection formula based on the parameter field:
· On the 'Report' menu, click 'Edit Selection Formula', then point to
'Record'. This opens the Record Selection Formula Editor.
· Type the following formula:
//For {table.field}, substitute the actual database field
// used in step 2 to link the main report to the subreport's
//stored procedure parameter
{?Main Parameter) = {table.field}
· Save the formula and close the Formula Editor.
When you next refresh the report, you will be prompted to enter a value which will be passed to the stored procedure parameter in the subreport.