Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Not show corrent value in Report Header Post Reply Post New Topic
Author Message
Saqibmalick
Newbie
Newbie
Avatar

Joined: 10 Aug 2009
Online Status: Offline
Posts: 4
Quote Saqibmalick Replybullet Topic: Not show corrent value in Report Header
    Posted: 10 Aug 2009 at 11:38pm
These total in my report header and it is not show the actual value only zero is showing, while that in my report footer it is showing correct value, what is the problem, what should I do to take same value in my report header.

Total_Amount (Field_Name) in CR
--------------------------
WhilePrintingRecords;
Shared NumberVar Total_A;
Shared NumberVar Total_B;
Shared NumberVar Total_C;
Shared NumberVar Total_D;
Shared NumberVar Total_E;
Shared NumberVar Total_F;
Shared NumberVar Total_G;
Shared NumberVar Total_H;
Shared NumberVar Total_I;
Shared NumberVar TotalAmount;
TotalAmount := Total_A + Total_B + Total_C + Total_D + Total_E + Total_F + Total_G + Total_H + Total_I;
TotalAmount
Saqib
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 11 Aug 2009 at 5:58am
You formula only works WhilePrintingRecords...
Threfore you cannot show values until they have printed and then summed so it will work in a footer and not a header.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 11 Aug 2009 at 6:05am
DBlank is right, you will need to 'read' the records first.  I am guessing that a simple SUM or COUNT won't work, otherwise you wouldn't have the shared variables.  You could try a subreport, but then you will be reading all of your data at least twice.
IP IP Logged
Saqibmalick
Newbie
Newbie
Avatar

Joined: 10 Aug 2009
Online Status: Offline
Posts: 4
Quote Saqibmalick Replybullet Posted: 12 Aug 2009 at 10:20am
Thanks for reply,
but how I should solve this problem, have you any idea, please tell me.

Tahnks
Saqib
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Aug 2009 at 10:25am

Are you conditionally summing items or is this a straight SUM of 9 different columns?

IP IP Logged
Saqibmalick
Newbie
Newbie
Avatar

Joined: 10 Aug 2009
Online Status: Offline
Posts: 4
Quote Saqibmalick Replybullet Posted: 12 Aug 2009 at 10:45am
Actually I have 9 sub report, from where I am collecting Number of Student for granting Scholarship multiply by Amount of current year and after that in main report there Total sum in this main report.

In each report I am calculating Total_A, Total_B, and so on .... by using this formula.

WhilePrintingRecords;
Shared NumberVar Total_A :=
Count ({AmountSetup_Scholarship.CurrentYearAmount}, {Scholarship.S_CLASS}) * ToNumber ({AmountSetup_Scholarship.CurrentYearAmount})

And in Main Report I am using this formula to sum all Totals.

WhilePrintingRecords;
Shared NumberVar Total_A;
Shared NumberVar Total_B;
Shared NumberVar Total_C;
Shared NumberVar Total_D;
Shared NumberVar Total_E;
Shared NumberVar Total_F;
Shared NumberVar Total_G;
Shared NumberVar Total_H;
Shared NumberVar Total_I;
Shared NumberVar TotalAmount;
TotalAmount := Total_A + Total_B + Total_C + Total_D + Total_E + Total_F + Total_G + Total_H + Total_I;
TotalAmount

I hope you will be understand the whole scenario.
Saqib
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 12 Aug 2009 at 3:04pm
off hand, there is no easy way to accomplish what you are after.
 
There isn't much of a point to running 9 subreports just to get a value in a header. 
 
My standard answer, and it may not be feasible in this case, is to get the data from a stored proc.  You could have the stored proc get the values of the subreports and sum them up for you. 
 
Regardless of method, it is going to take some work, the stored proc will take longer to write, but will perform better than running subreports.  Subreports are easier to write but drag down performance of a report.
 
The choice is yours.
IP IP Logged
Saqibmalick
Newbie
Newbie
Avatar

Joined: 10 Aug 2009
Online Status: Offline
Posts: 4
Quote Saqibmalick Replybullet Posted: 28 Feb 2010 at 11:54pm
Thanks for guide me, I am unable to complete this task due to some private problems, Now I need to solve it.,

Please guide me how to use the stored procedure in this syenerio.

Thanks again,
Saqib
Saqib
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 01 Mar 2010 at 6:11am
the actual details to writing a stored proc can be found on the internet.
 
stored procs are basically batch files for SQL, ie a list of command to be executed, and the results can be used later.
 
depending on how you want to construct the report/stored proc, you can create lots of temp tables ( 1 per subreport ) then sum them up and store the result in a simpler table which is the last (and only) 'select' statement in the stored proc (so the one that Crystal sees) or you can incorporate all the information from each subreport into 1 super record and then you can print the 'subreports' based on grouping info, as all of the detail is one table.  You can even create and update a column in this super record to represent the total that you are looking for, and calculate it in the stored proc.
 
The paths are many and depend on how you want to display the information and what you are comfortable doing.
 
HTH
IP IP Logged
razzak
Newbie
Newbie
Avatar

Joined: 03 Mar 2010
Location: India
Online Status: Offline
Posts: 34
Quote razzak Replybullet Posted: 04 Mar 2010 at 3:57am
use WhileReadingRecords
Razzak Sayyed
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.016 seconds.