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!

Again Shared Variables

Status
Not open for further replies.

mcrisf

Programmer
Mar 2, 2005
31
US
Hi,
i am having this problem with shared variables:
1.Main report in the report footer GrandTotal of MTD Sales (i need to pass this to subreport)
2.subreport in the repor theader Sum(MTDGoals) (if i put this in other section of the report header i get 0)

Main report (define the shared var):
//@Share_MTD
whileprintingrecords;
shared numbervar x:=sum(@MTD);
x;

subreport (catch the shared var):

//@Variance_MTD

whileprintingrecords;
shared numbervar x
if Sum(MTDGoals)<> 0 then
Sum(MTDGoals)%x
else
0


problem:for @Variance_MTD i am getting always 0
everywhere i place it in the subreport...
any idea??
help please...thx


 
The subreport must be in a section below the one in which the shared variable in the main report is set. So place your formula in the report header above the report header section in which the subreport is located.

-LB

 
hi,
thx for the answer ..but it doesn't work....
I placed the shared var in the main report in the report footer and in the subreport in the report header....but i get always 0....
 
the problem is (i think) related to this
if I leave in the selection record (in the subreport) the links to the parameters of the main report, then i get 0 for the shared var.
 
You have it backwards. The formula for the grand total of sales should be in the report header and the subreport in the report footer (or in a section below the formula in the report header).

How are you linking the parameters?

-LB
 

this is the record selection in subreport:

month({vDW_KPI_SALES_INSTANT_OBJ.OBJDATE})<=int({?Pm-@MonthToNumber}) and
year({vDW_KPI_SALES_INSTANT_OBJ.OBJDATE})=int(tonumber({?Pm-?Year})) and
{vDW_KPI_SALES_INSTANT_OBJ.SALESREP_ID}={?Pm-?SalesRep}
 
If you have more than one parameter value for each of the parameters, the linking will cause the subreport only to pick up on one value from the main report, because of the positionn of the subreport. Instead, create the same parameters in the subreport as in the main report, and then link the parameters to each other in the subreport linking screen. Use the dropdown in the lower left to select the actual subreport parameter, e.g., {?Year}, not the default {?pm-?Year}, for each parameter.

Fixing this alone will not solve the shared variable issue though--you need to position the formula and subreport correctly also.

-LB
 
i created the same parameters in the subreport, but i cannot link these parameters to the main report's parameters...i dont see the subreport's parameters in the linking screen....
 
Why is there a int(tonumber()) being used? Is the parameter a string, and why is that?

And you shouldn't require an int anyway.

I'd rewrite the record selection to:

{vDW_KPI_SALES_INSTANT_OBJ.OBJDATE}) < datserial({?Pm-?Year},{?Pm-@MonthToNumber}+1,1)
and
{vDW_KPI_SALES_INSTANT_OBJ.SALESREP_ID}={?Pm-?SalesRep}

This should prove faster as well.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top