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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subreport Formula 1

Status
Not open for further replies.

kuberacupidagra

Programmer
Oct 21, 2005
36
US
Hello All,

I am passing two values from the Main Report to a subreport as follows:

***** Main Report ****
whileprintingrecords;
shared numbervar MainVal1 :={#RTotal1};
shared numbervar MainVal2 :={@CurrentPRTMSum};

**** Declaring the following in subreport ****
whileprintingrecords;
shared numbervar MainVal1;
shared numbervar MainVal2;

@CurrentDollarPRTM is:
if MainVal1 = 0 then 0 else
({@CurrentDollarBCWS}/ MainVal1) * MainVal2;

Formula @CurrentDollarPRTM works fine. However when I go to Field Explorer and browse the data there is NO data showing. Also when I try to Summarize the formaula @CurrentDollarPRTM, I don't see the formula in the Insert->Summary.

What could be going wrong? Thanks for your help.

AA
 
However when I go to Field Explorer and browse the data there is NO data showing"

browse data browses what's in your database.

I don't think that it will be available for a insert->summary tyoe of aggregate, you'll need to roll your own.

I guess what you want is to sum the values in the subreport?

You don't show what's in: @CurrentDollarPRTM, nor do you state what sections these formulas reside. I'll assume you know that the subreport has to fire AFTER (be in a section after) the formulas in the main report have completed.

Anyway, try:

***** Main Report Repoort Header ****
whileprintingrecords;
shared numbervar MySum:=0

Not sure where your main report formulas are, but they can't be in the report header.

***** Subreport *****
whileprintingrecords;
shared numbervar MainVal1;
shared numbervar MainVal2;
shared numbervar CurrVal;
shared numbervar MySum;
//@CurrentDollarPRTM is:
if MainVal1 = 0 then
Currval:=0
else
Currval:=({@CurrentDollarBCWS}/ MainVal1) * MainVal2;
MySum:=MySum+Currval;
Currval

Now you can reference MySum elsewhere.

-k
 
You need to describe your report structure, including groups, the section in which you are creating the shared variables in the main report, where the subreport is located.

-LB
 
Hello Synapsevampire and lbass,

Thanks for your response.

The formula @CurrentDollarPRTM placed in the subreport Group Header gives correct result. It returns Currval.

A similar formula @CurrentDollarPRTMSum(Placed in Report Footer) returns MySum instead of Currval does not return any value. The field is blank...I have placed this in the Report Footer.


***** Main Report ****

The below formula is in Main Report formula section
@MainValues
whileprintingrecords;
shared numbervar MainVal1 :={#RTotal1};
shared numbervar MainVal2 :={@CurrentPRTMSum};
shared numbervar MySum:=0;


The below formulae are in the Subreport formula section

@CurrentDollarPRTM(Placed in Group Header 1)
whileprintingrecords;
shared numbervar MainVal1;
shared numbervar MainVal2;
shared numbervar CurrVal;
shared numbervar MySum;

if MainVal1 = 0 then Currval :=0
else
Currval :=({@CurrentDollarBCWS}/ MainVal1) * MainVal2;
MySum:=MySum + Currval;
Currval

@CurrentDollarPRTMSum(Placed in Report Footer)(This returns an empty value ?) What could I be doing wrong?

whileprintingrecords;
shared numbervar MainVal1;
shared numbervar MainVal2;
shared numbervar CurrVal;
shared numbervar MySum;

if MainVal1 = 0 then Currval :=0
else
Currval :=({@CurrentDollarBCWS}/ MainVal1) * MainVal2;
MySum:=MySum + Currval;
MySum

There is one Group in the subreport caleld DOLLARS.DESC

Thanks,

AA
 
I am using the following to get the Total(MySum) in the subreport.

In GROUP Header
whileprintingrecords;
shared numbervar MainVal1;
shared numbervar MainVal2;
shared numbervar CurrVal;
shared numbervar MySum:=0;

if MainVal1 = 0 then Currval :=0
else
Currval :=({@CurrentDollarBCWS}/ MainVal1) * MainVal2;
MySum:=MySum + Currval;
Currval


In REPORT Footer:
whileprintingrecords;
shared numbervar MySum;
MySum;

The values of Currval in Group Header are correct. However, I get a zero for MySum in the Report Footer.

What could i be doing wrong?

Thanks,

AA
 
Can't tell what sections ("formula section" is not a section) you are referring to in the subreport and in the main report. In your last post, it is unclear whether you are referring to the subreport report footer or the main report report footer. It is also important to understand where the subreport is located in the main report, and how it is linked. I did ask this before. For quality responses, it is important to answer all questions.

Not sure, but at least do not set the variable MySum to 0 in the formula in which you are trying to accumulate MySum.

-LB
 
Thanks a LOT lbass.

I was setting the variable MySum to 0 in the formula in which I was trying to accumulate MySum. I have corrected it and now the Sum of @CurrentDollarBCWP adds up correctly in the Report Footer of the subreport.

Below is the summary of the report and subreport.

1) The Main Report is Cost Performance on Hours(Hours.rpt)

2) The Subreport is Cost Performance on Dollars(Dollars.rpt)

I have linked the two reports using the two parameter fields

a) ReportPeriodStart b) ReportPeriodEnd

The Subreport(Dollars.rpt) is located in the Page Footer section of the Main Report(Hours.rpt)

I was having problems with finding the Total of the formula field @CurrentDollarBCWP which is located in the Group Header. This problem has now been corrected.

Thanks and Best Regards,

AA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top