Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Solved: Get accumulate amount in group Post Reply Post New Topic
Author Message
overcharge
Newbie
Newbie
Avatar

Joined: 12 Mar 2010
Location: Malaysia
Online Status: Offline
Posts: 12
Quote overcharge Replybullet Topic: Solved: Get accumulate amount in group
     Posted: 22 Apr 2010 at 3:57pm
Hi Experts,

Now i'm facing a problem for calculating sum.

ProgTitle(PK)  ProgID  SeqNo  Duration(MMSS)             Show Time(HHMMSS)
       1                  12        0        0300                                  070000
       2                  12        1        0200                                  070300
       3                  12        2        0250                                  070500
       4                  13        0        0100                                  080000
       5                  13        1        0146                                  080146 
       6                  15        0        0201                                  090000

Above is my data, my problem is how to show the Show Time column in my CR report. Cry

When SeqNO= 0, i need to refer start time from another table which is linked with ProgID.

For example, for ProgTitle=1 and SeqNO=0, it means that the start time 070000, for ProgTitle=2, the show time is start time + 1st duration which is 0700000 + 3min = 070300... etc

We can see that there is a pattern. When the ProgID is same, we refer to the same start time and need to calculate its Show Time.

Any advices for me to solve this problem? Thank in advance.

 


Edited by overcharge - 04 May 2010 at 7:27pm
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 23 Apr 2010 at 3:23am

global array would seem to be the solution...your title suggests the solution.

I haven't used them, but they're like any other variable that you will be accessing through a formula. 
In the group header (usually) you will reset the array...
for an array redim will reinitialize the array.
 
you will need to increment it, and in this case access it at the same time.
redim preserve will all you to grow the array...if you have a limit that is large enough, you can skip this step  (say you dim the array to be 20 and you will only get 10...no need to redim preserve as it will only slow the machine down...all sorts of redim preserver strategies--grow by 10 for example) but I digress.  Once you have the array member, you assign it a value from your data.  Depending on how the formulas work, you may want a counter so you know what line you're on to access the correct array member(s) and add it to the value that is displayed.
 
I know general, CR help is available for most of this, vb6 will help as well as most of the syntax is from vb6.
Last proviso, CR arrays are only 1 dimension, so if you need to store more than 1 piece of information, either store it as a delimited string in 1 array or have multiple arrays running at the same time all index the same.
 
HTH
IP IP Logged
overcharge
Newbie
Newbie
Avatar

Joined: 12 Mar 2010
Location: Malaysia
Online Status: Offline
Posts: 12
Quote overcharge Replybullet Posted: 28 Apr 2010 at 9:49pm
thank lockwelle, i found a solution.

It is using running total field, i did not need to deal with array.
Running total count need to reset based on ProgID.

At first i count the duration and start time in to second, sum them up and finally apply a formula to them back to HH:MM:SS format.

My code is something like:
showTime:={starttime}+{#sumSec}-{durationSec};

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