Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: FNG needs help! Post Reply Post New Topic
Author Message
will2know
Newbie
Newbie
Avatar

Joined: 04 Jun 2010
Online Status: Offline
Posts: 1
Quote will2know Replybullet Topic: FNG needs help!
     Posted: 04 Jun 2010 at 4:48am
I am attempting to make some changes to a pre-existing crystal report that has several subreports.  In these subreports data is displayed based off two groupings regarding the locations and address id's of customers.  What I want to do is to take the estimated rebated for each location on each subreport and add it together.  From the internet research I have been doing it seems like I need to use shared variables to pass information from the sub reports to the main report so I can manipulate the data to give me the results I want to display.  I think I figured out how to initialize and assign values to the shared variables through Shared numberVar custrebateloc10.  Do I just call the shared variable in the main report?  I see there is an organizational requirement to this whole process, such as intializing and assigning value to the variable before attempting to call it.  So should I just rearrange the sub reports and main report so that the sub reports execute first?  Whats the best way to do that?
 
The real problem I am running into is in the subreport I am calculating the estimated rebate for each customer and displaying it based off grouping and I am passing it to the shared variable but I am only getting the last rebate for last location calculated to display.  How can I push the value for each rebate/location to the main report for calculation?  I seem to only be able to get the last iteration, whereas I need each iteration.
 
I am quite new to Crystal Reports and I hope this makes sense.  Thank you for the time and consideration.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 07 Jun 2010 at 3:37am

declaring and initializing a variable is as simple as:

shared numbervar x;
 
if you need to reset the value, say in a group heading
shared numbervar x:=0;
 
to access it in a formula:
shared numbervar x;
dostuff
...
x := x +1//increments it for example...once it is declared in the formula, you can use just like a field or function etc.
 
The more complex issue: 
your subreport has several groups in it, and you want to report back on the groups individually...
 
You can pass a shared array, probably 2, 1 for location and 1 for value, back to the main report which can iterate through the array to find the value that it needs to display(since I doubt it needs to display all at once) or you can use a delimited string of location delimiter value diffDelimiter and use that to pass values back and forth.
 
As for where the subreport is, it needs to run before the display of its information in the main report.  If it only runs once, its position is going to be different than if there are parameters to the subreport and it is run multiple times.
 
HTH
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