Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maximum

Status
Not open for further replies.

crystalbeginner15

Programmer
Sep 6, 2005
76
US
I am using CR11. I have main report with two groups i)date and the other hour
sample report I get the volume fo each hour for each type(1,2,3.....10) for a day

date 1 2 3 4 5 6 7 8 10 total
xx
h1
h2
h3


h24

I have a subreport which calculates the peak volume for a day so I need to find the maximum of the total column

The way I did total in my main report is by adding a summary(which adds all the volumes for 1-10 types for each hour). I declared the suumary for total field as shared so that I can access it in my subreport but when i try to use the maximum function passing the shared variable it complains a field is needed.

Is there any other way of doing it or am I am missing anything.

Thank you.
 
It has been awhile since I did something like this, but since no one else has tried to answer your question yet, I figured I would give it a try.

One thing I remember from passing variables to a subreport was that the variable had to be declared in a section above the section where the subreport is placed. Is your subreport below the spot where you variable is declared?

If anyone else has a better idea, I would be glad to hear it.

HTH,

Jason
 
A shared variable will have a value of zero in the section that calls the subreport, but I'd expect it to be possible to write code to find a maximum, even thoguht the answer would not be sensible. So I suspect crystalbeginner15 has some other problem.

If the value is If it was a currency value, you'd do it like this:
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved:={#TotSaved};
SumSaved
And to access it in the main report, create another formula field with
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved

Further processing would be based on the formual field, not SumSaved.

Does this help? If not, please post the code that is being rejected.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
I did the same way and I am trying to access the shared varible from subreport in the main report and I get the
result as zero.here is the code which I wrote in the main report.
whileprintingrecords;
shared numbervar moncount;
shared numbervar tuecount;
shared numbervar wedcount;
shared numbervar thurcount;
shared numbervar fricount;
shared numbervar satcount;
shared numbervar suncount;
numbervar totaldays;
totaldays:=moncount+tuecount+wedcount+thurcount+fricount+satcount+suncount;

ToText(Minimum({?Date})) + " - " + ToText(Maximum({?Date}))
+" (" + ToText(totaldays,0) +
"days" + ")"

and I wrote in the subreport for each weekday count.
whileprintingrecords;
shared numberVar moncount:={#monCount};
moncount
 
Which sections of the report are the formula and the subreport in ?

The value of the shared variable will only be available in the main report in sections below the section containing the subreport.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
do you mean the formula is in the section above the section containing the subreport ?

If so then that is why the value is zero. As I said you need to move the subreport up or the formula down.



Gary Parker
MIS Data Analyst
Manchester, England
 
so I moved the formula down that is put it in the subreport
and tried to access the totaldays still I get zero.
 
Please give more spcific details about the layout of your report or I can only reiterate what I have already said

The value of the shared variable will only be available in to the main report in sections below the section containing the subreport.


Gary Parker
MIS Data Analyst
Manchester, England
 
Actually I am trying to use the formula in the report header and not in the main report.
 
the report header of what ?

You said :

I am trying to access the shared varible from subreport in the main report

If you want help then please provide the information requested about your report layout.



Gary Parker
MIS Data Analyst
Manchester, England
 
Sorry for the confusion.

I have report header for the report and the report consist of a main report and a subreport
In the reportheader I am tring to give a text which uses a formula(which is in the subreport)

Instead of using the formula I thought let me use the running total when I use it in the subreport its giving the correct vale but when I try to access the running total fiel in the report header it gives as one but I should get 4
 
Hi,
As has been explained, data produced by a subreport ( of any kind) does not exist until the subreport has run..Therefore when the Report Header prints ( it is the first thing displayed), there is no data from the subreport for it to use, since it has not run yet.
Put the formula in the report footer and see the difference.





[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top