Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Running Total using global variable Post Reply Post New Topic
Author Message
justin
Newbie
Newbie
Avatar

Joined: 26 Mar 2009
Location: Australia
Online Status: Offline
Posts: 6
Quote justin Replybullet Topic: Running Total using global variable
    Posted: 26 Mar 2009 at 4:45pm
Hi,

I'm using cr 2008 and am trying to get a running total going in my report but it is not working as expected.
All the formulas are on the main report (no subreports).
I have a formula in the page header like so:

Global NumberVar x;
x := {auarstmh.bal_opn}

This displays the correct value from auarstmh.bal_opn on the report.

In the details section I have this:

Global NumberVar x;
x := x + {auarstmw.trn_val}

Which doesn't display the correct values.   auarstmw.trn_val is a field in the details section.

For example on one report the values are:

Report Header
auarstmh.bal_opn formula = 4063.70

Details
auarstmw.trn_val = 5.30
formula = 1637.40 (according to my formula this should be 4063.70 + 5.30 = 4069.00)
-----------------------------------------
Another example with two detail records:

Report Header
auarstmh.bal_opn formula = 1798.20

Details
auarstmw.trn_val = 26.50
formula = -3279.54 (according to my formula this should be 1798.20 + 26.50 = 1824.70)

auarstmw.trn_val = 54.60
formula = 1852.80 (according to my formula this should be 1824.70 + 54.60 = 1879.30)

I hope I have made this clear enough.  It seems it must be a simple mistake I am making as it doesn't look hard at all!

thanks in advance

justin
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 27 Mar 2009 at 6:26am
I don't use Globals, I use shared, but I wouldn't think that there is much of difference.  Since the formulas look right, the only thing comes to mind is if there are suppressed records or multiple records.
 
I am assuming that the record changes every page...if it associated with a group that is causing the report to generate a new page, perhaps you can move your formula from the page header to the group header as maybe there is some interaction there.  I have tried striping a page, and oddly enough do not get consistent results, so I wonder about formulas in the page header section.
 
Hope some of this helped
IP IP Logged
justin
Newbie
Newbie
Avatar

Joined: 26 Mar 2009
Location: Australia
Online Status: Offline
Posts: 6
Quote justin Replybullet Posted: 30 Mar 2009 at 4:10pm
Thanks for the reply lockwell.

I have checked the suppressed records suggestion but from looking directly at the tables the data is being pulled from, there are no records being suppressed.

I'll try the suggestion of shifting the page header formula to different areas and see if that helps.

justin
IP IP Logged
justin
Newbie
Newbie
Avatar

Joined: 26 Mar 2009
Location: Australia
Online Status: Offline
Posts: 6
Quote justin Replybullet Posted: 30 Mar 2009 at 4:29pm
Ahhhh, I'm such an idiot!

It was what you said lockwell about using a shared variable rather than a global variable.  I decided to try that and it worked!

The report I am working on wasn't originally created by me, I am just modifying it for someone.  After going through all the other formulas again, I finally found one little section of a formula where they use the same Global variable that I was using, so they were conflicting with each other.

When modifying an existing report I normally append my initials to any new variables I create to ensure there are no conflicts, but I didn't in this case for some reason.  Teaches me a lesson!
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.035 seconds.