Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Dynamic calculations from Subreports Post Reply Post New Topic
Author Message
adamcar
Newbie
Newbie


Joined: 08 Nov 2011
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote adamcar Replybullet Topic: Dynamic calculations from Subreports
    Posted: 08 Nov 2011 at 2:01am

I need to know if the following calculations are possible to do with Crystal Reports.

This is my current report which works:

 I have 3 sub  reports in 1 main report . In each sub report there are  field values that are used to make a calculation in  the main report. At the moment each value in the subreport is a single value  (based on 1 month has 1 single value) .

 So for a montly report

Month 1

Subreport 1 = Value 1

Subreport 2 = Value 1

Subreport 2 = Value 1

 

Main report Footer Calculation

Subreport 1 .Value 1 + Subreport 2.Value 1  + Subreport 3.Value 1

 

This works fine if I run the report for a single month. However I want to run the report for a period of  time (i.e. 4 months  + so I don't have to run the report 4 times). I have worked out how to bring multiple values into each of the subreport but how do i calculate them in the footer

Subreport 1 = Value 1 (Month1)

Subreport 1 = Value 2 (Month2)

Subreport 1 = Value 3(Month3)

Subreport 1 = Value 4(Month4)

 

Subreport 2 = Value 1(Month1)

Subreport 2 = Value 2(Month2)

Subreport 2 = Value 3(Month3)

Subreport 2 = Value 4(Month4)

 

Subreport 3 = Value 1(Month1)

Subreport 3 = Value 2(Month2)

Subreport 3 = Value 3(Month3)

Subreport 3 = Value 4(Month4)

 

Main report Footer Calculation

Month 1

Subreport 1 .Value 1 + Subreport 2.Value 1  + Subreport 13.Value 1

 

Month 2

Subreport 1 .Value 2 + Subreport 2.Value 2  + Subreport 13.Value 2

 

Month 3

Subreport 1 .Value 3 + Subreport 2.Value 3  + Subreport 13.Value 3

 

Month 4

Subreport 1 .Value 4 + Subreport 2.Value 4  + Subreport 13.Value 4

 

Can this be done in crystal? Any help  is very much appreciated.

 Thanks

 



Edited by adamcar - 08 Nov 2011 at 2:02am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 08 Nov 2011 at 3:33am
you would need for your subreports to be able to identify each month and place the correct values into either an array or separate variables that the main report can then utilize.
IP IP Logged
adamcar
Newbie
Newbie


Joined: 08 Nov 2011
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote adamcar Replybullet Posted: 10 Nov 2011 at 2:32am
Thank you, I have created an array in the subreport which looks like this. I am trying to put in each monthly value in the array.

WhilePrintingRecords;

Shared NumberVar Array xx;
ReDim xx[2];
Local NumberVar i;
for i :=1 to 12 Do
{
    xx := {@frmMontlyDurationS2}
};


How do I return the array results from my formula field?

Also in my main report I am trying to access them but when I do I just get the last value that was assigned to my array in my subreport.

This is what I have in my main report in my footer in a formular field

WhilePrintingRecords;
if (count(Shared NumberVar Array xx) > 0 then xx[0];

Any pointer on this and how to dynamically retrieve the array.

Thank you.

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 10 Nov 2011 at 2:59am
I would think that you would access in the main report like:
shared numbervar array xx
 
if ubound(xx) > 0 then xx[1]
 
I don't think CR starts its array index at 0...not to mention, you started filling the array at 1...
 
you also set the size of the array at 2, not 12, so I have no idea what is happening (redim xx[2])
 
as another note, how does {@frmMontlyDurationsS2} know which index it is to be using? 
 
HTH
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.030 seconds.