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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Summarizing shared value from sub report in main report 1

Status
Not open for further replies.

rbarekere

Technical User
Mar 2, 2009
29
US
lbass previously gave a suggestion on summarizing shared value from sub report in main report by resetting the shared value in group.

It really worked well.

I have another situation where in main report grouped based on A in GH1a.

Now the sub report is located in GH1b.

Now I want a total in Report Footer. I tried resetting shared value in GH1a to zero. But then RF was showing me last Gh1b value.

If I dont reset at Gh1a then chances are there for some values of main report (Gh1a) there might be no value in sub report so first total will repeat in another resulting in wrong value.

Is there any way i can assign a value 0 if the shared value is null.
 
More information on the above problem.

As I have told I have reset value in GH1a.

Now say I have 3 Gh1a values say A, B and C.

Then sub report value for A is 100, no value for B and for C value is 100.

If I select only A and B in parameter then i get the report footer total as 100 which is correct.

If I select B and C then also total is 100 which is correct.

But when I select A, B and C then the total is still 100 as it has reset it while C.

But if I remove reset formula then the total will be 300 where as correct total should be 200.
 
Is there any way i can pass all values A, B and C to sub report and calculate the Grand total in Report footer. Then present the subreport in the Report Footer of Main report?
 
This is the piece of information I got from some one

Passing a multiple value parameter to a subreport is allowed. I would suggest letting Crystal Report create the parameter in the subreport. Try following these steps:


1. Create the multiple value parameter in the main report
2. Create/ insert your subreport into the main report
3. Edit the subreport links (Edit menu):

a. Highlight and move the parameter field to the right box
b. A new parameter name will appear in the lower left corner combo box {?PM-blah blah blah}.
c. Select the field in the subreport that will be used in the Record Selection against your new parameter field.



I verified this it works well for Multiple parameter but along with Multiple value if it has Range then the sub report becomes blank.

Any Idea to get this working.
 
The issue is that you have to use a different variable to sum the shared variable in the main report. So leave your reset in GH1a, your sub in GH1b, and then in GH1c, you can accumulate the shared variable while also displaying it if you like:

whileprintingrecords;
shared numbervar amt; //your shared variable here
numbervar sumvar := sumvar + amt; //this accumulates here
amt //displays the current shared variable

Then in the report footer, use the following display formula:

whileprintingrecords;
numbervar sumvar;

-LB
 
I tried exactly the same.

For Ex: I have 3 records for Gh1b. 1) 2,200 2) null and 3) 500.

Gh1c value respectively displays 1) 2,200 2)2,200 and 3)500

Finally RF value is 500.

Here is the reset formula for GH1a
numbervar Proj_Balance;
if not inrepeatedgroupheader then
Proj_Balance:=0;


formula for GH1c
whileprintingrecords;
shared numbervar Balance;
numbervar Proj_Balance:= Proj_Balance + Balance;
Balance

Formula for RF
WhileprintingRecords;
Numbervar Proj_Balance;


 
You are resetting the wrong variable. Your reset formula in GHa should be:

whileprintingrecords;
shared numbervar Balance;
if not inrepeatedgroupheader then
Balance:=0;

This will prevent the null value to take on the value from the previous subreport execution. You don't want to reset the variable that you are using to accumulate for the grand total.

-LB
 
Thanks LB.

I did the same mistake in another one. It seemed to me like it is working !

Thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top