Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Shared Data Sub\Main Report HELP!! Post Reply Post New Topic
Author Message
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Topic: Shared Data Sub\Main Report HELP!!
     Posted: 19 Sep 2011 at 4:02am
Hi..
 
I have a subreport with the formula Adjustedtotal
 
(If IsNUll({PAYMENT.AMOUNT}) Then 0
Else {PAYMENT.AMOUNT})+Sum ({@Adjustedment_Amount})
 
which is in the report footer in the sub report
it then display in the details section of the main report
 
it is grouped by location in the Main.
I want to sum the Adjustedtotal in the group footer in the main report..
 
Im thinking I have to use whileprintingrecords?
But not sure how to setuo.
 
Any ideas, or samples?
 
Thanks
 
 


Edited by jbalbo - 19 Sep 2011 at 4:03am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Sep 2011 at 4:11am
you have to make it a shared variable from the sub report to the main report and pass teh value back to the main report (on a detail B section) which can then be summed per group or for the whole report.
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 19 Sep 2011 at 4:15am
Thanks for getting back so quick..
Can you give me an example of how I do that.. ??
 
Thx
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Sep 2011 at 4:20am
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 19 Sep 2011 at 4:20am
ok so i changed the subreport formula to this?
 
WhileprintingRecords;
shared CurrencyVar totals;
(If IsNUll({PAYMENT.AMOUNT}) Then totals := 0
Else totals :={PAYMENT.AMOUNT})+Sum ({@Adjustedment_Amount})
 
Is this right?
 
then how do total by loaction and grandtotal on the main report??
 
 
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 19 Sep 2011 at 4:46am
The link does work..
and I got it "Kind of" working like this..
subreport has function called Subs
 
WhilePrintingRecords;
Shared currencyVar sTotal := stotal + ({@Adjusted_Payment_Amount})
 
with subs in the details section of subreport.
 
Mainreport has function GroupSubTotal in the group footer
 
WhileprintingRecords;
shared CurrencyVar stotal;
 
Im getting the values, but how do i now reset the stotal fter each group?
 
Thanks Again!!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Sep 2011 at 4:49am
in the main report you need 3 formulas
0ne to set it to 0 (group header)
One to sum it (per row)
One to display it (group footer)
 
 


Edited by DBlank - 19 Sep 2011 at 4:50am
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 19 Sep 2011 at 5:01am
so I shouldnt sum in the sub report?
if not what should the subreport function look like and how would I add thein in the detail section of the main ?
 
Thx..
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Sep 2011 at 6:54am
YOu need to sum in both palces.
in the subreport (SR) you need to sum in order to pass one final value for that instance of the SR to the main report (MR).
In the MR you then also need to sum each row (passed summed sr value).
 
All this being said, i hate subreports (especially on the detail section) and avoid them whenever possible. Sometimes you can't and this might be that time but they tend to kill performance. I try to get everyting into the main report. Then suppress items/rows/groups I do not need. I then use conditionaly running totals (others prefer variable formulas) to get summarized values.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum