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

Problem passing variable from subreport to main for a total

Status
Not open for further replies.
Feb 25, 2004
79
US
Hello good people,

Have a small problem with a formula totaling shared numbervars from a subreport. CR10 from Pervasive SQL DB.

Here is a formula from one of my subreports
Code:
whileprintingrecords;
if isnull({#RTotal0})
    then shared numbervar Glulam_Total := 0
    else shared numbervar Glulam_Total := {#RTotal0};

There are a few more similar to this you will see them in the next section for their names.

Here is the formula that is having a problem totaling. This formula is located a section below the subreports in the report footer a/b.
Code:
whileprintingrecords;
shared numbervar Plywood_Total;
shared numbervar Lumber_Total;
shared numbervar Glulam_Total;
shared numbervar Hardware_Total;
shared numbervar Hybrid_Total;
shared numbervar Truss_Total;

Plywood_Total + Lumber_Total + Glulam_Total + Hardware_Total + Hybrid_Total + Truss_Total + {@Addon_11};

I may have a problem with the way I am writing these formulas could someone please review and see if anything looks incorrect?

Thanks all,
Rob
 
The formulas look okay. What is the problem you're experiencing?

-LB
 
Hello LB,

The problem is that the totals are not being pulled from the subreports. It only takes the value of {@Addon_11}.
 
The formulas in the subreports must be placed in the subreport report footer.

Also, I would have written the formula like this:

whileprintingrecords;
shared numbervar Glulam_Total;
if isnull({#RTotal0}) then
Glulam_Total := 0 else
Glulam_Total := {#RTotal0};

Assuming the subs are in RF_a an RF_b, your main report formula should be in RF_c.

-LB
 
Ok I got all the formulas cleaned up as you advised, all of the totals formulas are placed in the subreport footer, the subreports are placed in subsequent report footers above the total formula.

I am still not seeing anything add up. I will keep looking for a problem.

Thanks and any more suggestions are welcome!

Rob
 
Did you hide or suppress the subreports or the sections containing the subreports? You can't do that.

-LB
 
The sections in the subreport are supressed, such as the details and the headers, come to think of it, the formula is supressed in the report footer in the subreport.

I will make a few changes and let you know, thanks.
Rob
 
LB,

I have un-supressed the formulas from the subreports. The data seems to be passing properly as I have added new formulas containing only this:

Code:
whileprintingrecords;
shared numbervar Plywood_Total;
Plywood_Total;

on my main report next to the total we talked about above. They are all showing values even one resulted in 0 which means the other part of the formula is working in changing the null to 0.

The problem must be in the total formula from what I can tell. I could substitute the variables in the total formula with the test variables I just created, but I still want to know why the original formula does not work.

I will explore further.
 
When I made the changes and to the total formula it changed all of the test formula results to 0.

 
Got it. There was a total formula in an above section in the report footer messing things up. I moved those sections below the ones we were working in. Working well now.

Thank you for walking me through it LB!

Code:
YOU ROCK!

Rob
 
I am having trouble passing a Shared Variable. I need it to pass from the first occurance of the subreport, up to possibly 5 times the subreport runs. This is determined by the data. Just testing, I placed a test in the main report and I don't get anything in the subreports.

Shared stringVar SubjLandVal := "TEST" ; //Main report

Shared StringVar SubjLandVal ; //Subreport
 
Did you place the main report formula on the main report somewhere? The subreport must be located in a section below the one in the main report where you set the value.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top