Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Shared Variables Post Reply Post New Topic
Author Message
Sherrie
Newbie
Newbie
Avatar

Joined: 28 Sep 2009
Location: United States
Online Status: Offline
Posts: 4
Quote Sherrie Replybullet Topic: Shared Variables
     Posted: 28 Sep 2009 at 1:50pm
I have accomplished my first shared variable from a subreport to the main report. Yea!!Smile
 
Now I'm stumped.  Can't seem to get the variable to sum or do anything with it.  Help please!Confused
 
My shared variable from my subreport is a total of currency for labor and marterial cost against a work order.   The sub-report is linked to main report by showing the cost per asset.
 
When I am in the main report and try to do a summary for the shared variable, it is not in my report fields to select.  I can't seem to find it anywhere.  Does anyone know how I can find my shared variable to make a summary on it for a grouping.  The grouping is according to the age of the asset.


Edited by Sherrie - 29 Sep 2009 at 8:03am
Sherrie
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 29 Sep 2009 at 8:02am
Depends on what you want to do.  If you want to display it, you need to write another formula, and it you want to increment it, you need to write another formula.
 
Lots of formulas...
 
HTH
IP IP Logged
Sherrie
Newbie
Newbie
Avatar

Joined: 28 Sep 2009
Location: United States
Online Status: Offline
Posts: 4
Quote Sherrie Replybullet Posted: 29 Sep 2009 at 8:10am

My shared variable is displayed.  I am trying to use it to make a summary on a grouping.

My shared variable is from my subreport.  The variable is the total for the cost of labor and material that is charged towards a work order number.

The work order number is then linked to the main report via the appropriate asset that the work order was on.  In the main report I now have the asset information which includes the age.  There is a grouping on the ages of the assets.   The shared varible shows on each asset.  I would like to take the shared variable and total all the cost per grouping of assets per age

Sherrie
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 29 Sep 2009 at 8:16am
you can't use the built in aggregate functions on a shared variable like this, as CR cannot determine it's value.  What you need to do is to create another variable (I always use shared) that will be an accumulator for the group, and then increment with the shared variable.  Then you can display it in the group footer and set it back to 0 in the header.
 
Is this more helpful?
 
IP IP Logged
Sherrie
Newbie
Newbie
Avatar

Joined: 28 Sep 2009
Location: United States
Online Status: Offline
Posts: 4
Quote Sherrie Replybullet Posted: 29 Sep 2009 at 8:29am
How?
Sherrie
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 29 Sep 2009 at 10:00am
basic variable formulas:
reset:
shared numbervar aVar := 0;
"" // hides the 0 display
 
increment
shared numbervar aVar := aVar + {table.field};
""//optional, you may want to see this in a detail record
 
could be: (this will take a value from a subreport add it to the accumulator and display the subreprot value.
shared number aSubReport;
shared numbervar aVar := aVar + aSubReport;
aSubReport
 
 
display
shared numbervar aVar
 
 
:= is assignment, = is equality testing,  ; needed at the end of all lines except the last.
 
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