Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: How to sum a shared variable Post Reply Post New Topic
Author Message
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Topic: How to sum a shared variable
    Posted: 06 Jul 2009 at 10:57pm
Hi All
 
I have spent most of the day on this and I feel I should be able to do this, this is my last resort.
 
Using Crystal XI I have a main report with some totals from a subreport using a shared variable. I have the shared variable displaying on my main report and all looks good. What I can't do is create the right formula or place the right formula on the report to get a total of these figures in the report footer.
 
Report looks like this
details a;
 
@sumtotal
whileprintingrecords;
numbervar sumtotal:=0;
 
details b;
subreport
 
details c;
@sum of shared
whileprintingrecords;
numbervar sumtotal;
shared numbervar lineamt;
sumtotal:=sumtotal+lineamt; (this calculates and displays fine)
 
RF;
whileprintingrecords;
numbervar sumtotal;  (this displays as 0)
 
What I need is a total of 'lineamt' in RF.
 
What have I done wrong??
 
Thanks very much
IP IP Logged
gurupran
Newbie
Newbie
Avatar

Joined: 25 Jun 2009
Location: India
Online Status: Offline
Posts: 6
Quote gurupran Replybullet Posted: 07 Jul 2009 at 4:40am
hi
 
u did small mistake.
 
u use sharedvariable but shows normal filed
 
want to print shared numbervar lineamt;
 
try this
 
shared numbervar sumtotal;
shared numbervar lineamt;
sumtotal:=sumtotal+lineamt;
 
In RF:
Shared numbervar lineamt;
 
its working sure
 
 
 
 
 
guru
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 07 Jul 2009 at 6:24am
It would seem that there is a record that is resetting your counter to 0 before the RF.
 
since you want a total of all lineamt, remove the formula that resets the total to 0.  Does this give you what you want?
 
If you want a total for a group and big total for the report, create another variable and increment that one as well, but never reset it, this way it will be the total for the report.
 
HTH
IP IP Logged
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Posted: 07 Jul 2009 at 6:16pm
Hi lockwelle
 
It certainly did help. I got rid of @sumtotal and I have my total. Thankyou so much, I have learnt yet something else about Crystal.
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.047 seconds.