Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: resetting variable Post Reply Post New Topic
Author Message
avaj
Newbie
Newbie


Joined: 26 Sep 2007
Online Status: Offline
Posts: 30
Quote avaj Replybullet Topic: resetting variable
    Posted: 31 Oct 2007 at 9:06am
CR XI
 
I have created a formula to summarize group totals so that I can then use that total as a sort option because I can't use the built-in running totals or summary for sorting.
 
Formula 1:
@total
    EvaluateAfter ({@accts});
    global numbervar total := total + {VENDOR_SALES.AMT_SOLD}
My report is designed as 3 groups (details are suppressed).  @total is placed in group footer 2
 
I seem to be getting the right totals but I can't get my reset variable to work properly.
 
Formula 2:
@reset total
  global numbervar total := 0
 
I have tried placing the reset in all the different group headers (& footers) & also tried using the different "timing" options. Nothing seems to work properly.
 
Any suggestions?
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 31 Oct 2007 at 10:41am
I am not entirerly clear about the issue you are experiencing. You say you are getting the correct totals but the reset is not working. If you are getting the correct amounts your reset must be working. When I create manual running totals I always use 'WhilePrintingRecords' as the evaluation pass to use. 
 
Perhaps I am particularly slow today, if so my apologies.  I am sure those on the forum would like to try to help. However, in my case I would benefit from a bit more explanation about the problem.
 
Regards,
 
John W.
 
 
 
IP IP Logged
avaj
Newbie
Newbie


Joined: 26 Sep 2007
Online Status: Offline
Posts: 30
Quote avaj Replybullet Posted: 01 Nov 2007 at 8:25am
The whole reason I need to do this manually is so that I can use the total as one of my sort options based on a user parameter.
 
When I say I am getting the correct totals I mean the totals for each group are being added together ok.  But I need to start back at zero for each group.  For example this is what I get now:

Cust 1

tkt A - $20

   tktB - $30

Total - $50

Cust 2
  tkt A - $10
  tkt B - $5
Total - $65
 
Cust 2 Total should be $15
 
If I use WhilePrinting it works great but I don't get the field in my sort option.  If I use EvaluateAfter I do.
 
The user wants to select from 8 different sort options.  This needs to be one of them.  If there is a better way to do this I'm open to suggestions.


Edited by avaj - 01 Nov 2007 at 8:25am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 01 Nov 2007 at 8:44am
The reason why you lose the formula when you do WhilePrintingRecords is because of the two-pass report processing model of CR. The sorting of the records is done PRIOR to printing the report, but your formula is being calculated DURING the printing of the report. Thus, it is not allowed to be selected as  a sort field. I'm not sure how to get around it, maybe someone else can pitch in here....
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
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.008 seconds.