Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Pulling Data from Sub-report Post Reply Post New Topic
Author Message
Jelly
Newbie
Newbie
Avatar

Joined: 13 Jan 2008
Location: Australia
Online Status: Offline
Posts: 6
Quote Jelly Replybullet Topic: Pulling Data from Sub-report
    Posted: 13 Jan 2008 at 10:04pm

Hi,

My CR knowledge is very limited so please bare with me.
 
I have a report that have a running total of formula fields (ie. SubTotal_A) and sub report that have a running total of a different formula fields (ie. SubTotal_B) . I'm trying to pull back this SubTotal_B from the sub report and add it to SubTotal_A to make Total_A+B. Both report uses the same store procedure for the data. They are in seperate reports because they sum the value in different ways.
 
-----------------------------
main report
GroupA
   DataA1  ValueA1
   DataA2  ValueA2
-----------------------------
                SubTotal_A
-----------------------------
subreport
    DataB   ValueB
-----------------------------
                SubTotal_B
-----------------------------
                TotalA+B
-----------------------------
 
My question is:
1. How can I pull the SubTotal_B from the sub report back to the main report so I can do some manipulation to make TotalA+B?
 
I have tried to add the same formula fields that's in the sub report to the main report, but it prints out as 0.0 in the main report and not the same value as the sub report. Is there another way of doing this?
 
Thanks,
 
 
 
 
Jelly
IP IP Logged
Savan
Senior Member
Senior Member
Avatar

Joined: 14 Dec 2007
Location: India
Online Status: Offline
Posts: 162
Quote Savan Replybullet Posted: 13 Jan 2008 at 10:22pm
HI Jelly
 
take a shared variable in sub report for i.e u have to decalre two variables. one is for initial value for declartion of the variable. Formula 1 would be as follows.
          initval (syntax is as follows)
          shared numbervar subtot := 0
 
place this initval in page header and supress it so that it will be initated to 0 each time a new page starts.
 
 2nd formula would be stot (syntax is as follows)
shared numbervar subtot := shared numbervar subtot + table.field
 
so you will get total stored in a shared variable.
 
now in the mainreport create one more formula as "subtotal" synatx is as follows
    shared numbervar subtot;
 
so u will get the total in main report.
 
now you can use that sub report total for further calculations i.e (tota a+b) Thumbs%20Up
 


Edited by Savan - 13 Jan 2008 at 10:26pm
Thanks
Savan
IP IP Logged
Jelly
Newbie
Newbie
Avatar

Joined: 13 Jan 2008
Location: Australia
Online Status: Offline
Posts: 6
Quote Jelly Replybullet Posted: 14 Jan 2008 at 3:38pm
Hi Savan,
 
Your solution works great. Thanks for your help! Clap
 
Cheers,
Jelly
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.032 seconds.