Joined: 29 Jan 2009
Online Status: Offline
Posts: 18
Topic: WhilePrintingRecords Error When Passed to Group Posted: 03 Aug 2009 at 5:44am
I have a few formulas that seem to be working well apart from one thing. I have a subreport and can successfully pass a value to them ain report. This value then goes into a formula that acts as a running total. The problem is that the running total seems to add the final value twice when I put this into a group. E.g.
A B C 1.00 3 1.00 15.50 5 16.50 0.00 1 16.50 0.00 1 16.50 24.00 2 40.50
Total in Details Section: 40.50 Total in Group Section: 64.50
Where col A is the value passed from the subreport, and C is the cumulative total. Ignore B! The maths from this indicates that as soon as the total enters the group, it redoes that final addition.
Is this an inherent problem with doing thins this way? Or have I missed something? Thanks!
CODE: SubReport: //@SubFormula //Stores the value of the {@TAT_AvTAM} field //in a number variable called 'myTotal'
Display Field – this is used to pass the above value to an accumulator field. This can then be used for calculations. WhilePrintingRecords; NumberVar TotalTAT:= {@TAT_SubReportLink} + TotalTAT;
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Posted: 03 Aug 2009 at 6:13am
Everything looks good until the last line. Wouldn't you use myTotal instead. I don't see where you are referencing the myTotal variable in the main report...ok, you are displaying it, but aren't using it in any calculations.
I would have thought that the last line would have been:
Numbervar TotalTAT := TotalTat + myTotal
this is assuming that the detail section calls the subreport, and not a group.
Joined: 29 Jan 2009
Online Status: Offline
Posts: 18
Posted: 03 Aug 2009 at 6:54am
I created a new formula to reference this (TAT_SubReportLink) which contains: (WhilePrintingRecords; Shared NumberVar myTotal; myTotal ) form the above. I putthat in to try and get my aching head around the While loops... but you are right. If I substitute the following it also works.
However, the error still occurs. The subreport value is in the detail section also. Is there a way to temrinate the while loop after the last vlaue? It's almost as if the forumula when it appears in a group does the same calaculation again, and takes the cumulative total and adds it to the last value. This thing works great as long as the forumula stays in the detials section.
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Posted: 03 Aug 2009 at 10:52am
what while loop? WhilePrintingRecords is a timing directive for Crystal. Crystal reads the data multiple times...I don't recall all the steps, but it is in help.
is this formula, where totalTat is incremented referenced anywhere else besides the details section? If so, it is going to increment the value totalTat by the amount of the last record read. If you want to report on the value, use the formula that is was in the Main Report of your original post:
Joined: 29 Jan 2009
Online Status: Offline
Posts: 18
Posted: 04 Aug 2009 at 12:57am
Originally posted by lockwelle
If you want to report on the value, use the formula that is was in the Main Report of your original post:
Numbervar TotalTAT
So I was on the right track originally? I tried passing the value into the new field but obviously was not doing it right - but that's what TotalTAT was for. If it is mearly acting as a conduit forthe vale form - probably because it weas refencing the original myTotal value?
The problem I have is that I get an error that the field cannot be summarised. I need the last value before the end of the group to be passed to a new field, which can then be used in the group summary at the bottom.
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Posted: 04 Aug 2009 at 6:08am
you cannot use the built in aggregate functions on variables. You need to 'provide' your own aggregates...so if you need a sum, you will need to define another variable and reset/increment/show the variable.
if you have lots of groups this can become quite busy.
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