Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suming a subreport and the main report? 1

Status
Not open for further replies.

johnism

Technical User
Jul 31, 2002
53
US
I need to create a grans total sum that is built off the sum of the main report and the sum of the subreport. Can this be done?
Thanks,
John
 
Yes, you need a shared variable to bring back the subreport sum to the main report. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Could you help with that part,not sure how to go about that?
Thanks,
John
 
You declare a shared variable in the subreport, and assign it the value that you want to store (the grand total).

You then declare the same shared variable in the main report and add it to the main report grand total.

It might help to look up "shared variables" in the Crystal help. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
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.
 
TRNCOLS,

I believe that is an explanation of linking subreports, not passing variables. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top