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!

Get the sum of formula from subrep. to main report

Status
Not open for further replies.

OLTU

Technical User
Feb 14, 2005
39
NL
Hi All,

I'm using crystal reports version 8.5.

I'm trying to get the sum@formula from my subreports to the main report and make a grand total of my all subreports.
the subreports are not linked to main report,because I don't want that.The results which I have are now 100% but It's very difficult to summarize the subreports qty's together,pls help.

Like:

qty 50 (subreportA)
qty 50 (subreportB)
qty 50 (subreportC)
qty 50 (subreportD)

total should be 200

I tried to make a formula like below:

//In subreport i've put the below on #report footer
whileprintingrecords;
numbervar totloc:=totloc+{@87.5% of Tot.Loc};

// then in main report I put the below on #report footer also

whileprintingrecords;
numbervar totloc;

// last I made a reset formula and put on page header
but it's still not working.

pls help.

 
Hi there,

You need to use a shared variable to pass the info from the subreport to the main report. i.e

shared numbervar totloc:=totloc+{@87.5% of Tot.Loc};

--main report formula

whileprintingrecords;
shared numbervar totloc;

If you don't put shared, local or global at the start it will automatically default to a global variable and although global variables can be used referred to anywhere in a report, they can't pass information from a subreport to the main report.

HTH
 
Hi,

Unfortunately it's still not working,
pls help me out of this f..king sh.t because I'm really puzzled here and this all on friday,I need to fresh my brain this evening :)

I tried in subrep formula

shared numbervar totloc:=totloc+{@87.5% of Tot.Loc}

And in main rep. formula

whileprintingrecords;
shared numbervar totloc;

thx,
MHP
 
A couple of questions...

Is the formula which uses the shared variable in the main report below the subreport?

Also have you called the shared variables a different name in each of the subreports?
 
-1.
formula:
shared numbervar totloc:=totloc+{@87.5% of Tot.Loc}
//this is in subreport and also the {@87.5% of Tot.Loc}
is in subreport.

formula:
whileprintingrecords;
shared numbervar totloc;
// this is in main report

-2.
No I'm now working with the first subreport if this works then I'll
do the same to the rest of my subreports,I' ll use different
names to the shared variables.

 
Another question have you got whileprintingrecords; at the top of your formula in you subreport?

Anthoer thing to try is in the variable in the subreport just assign the {@87.5% of Tot.Loc} to the variable instead of toloc + {@87.5% of Tot.Loc}. Its just a test to see whether the info is actually being stored properly or not.

Also can you temporarily remove the reset formula.

Let me know how that goes

 
yes the whileprintingrecords; is on the top of the formula
in subreport.

What dou exactly mean to assign the {@87.5% of Tot.Loc}.
how shall I do that,it's not clear to me.
pls give an example.
 
Hi,

If you use the following in your formula in the subreport

whileprintingrecords;
shared numbervar totloc:= {@87.5% of Tot.Loc}

Its really just to see if the information is actually being stored. Its also a good check to see if {@87.5% of Tot.Loc}
is actually holding any information as well
 
the problem is,
the formula in subreport is working but not in main report.

I tried also what you asked to me,
like//
shared numbervar totloc:= {@87.5% of Tot.Loc} then I get the same as shared numbervar totloc:= totloc +{@87.5% of Tot.Loc} in subreport,
in the main report it's not working,

I have my main report not linked with subreports,maybe this is the reason which he will not working?
 
You should have a different variable name for each subreport, e.g., totloc1, totloc2, etc. Let's assume your subreports are in separate report header sections. Then create a formula in the main report:

whileprintingrecords;
shared numbervar totloc1;
shared numbervar totloc2;
shared numbervar totloc3;
shared numbervar totloc4;
totloc1+totloc2+totloc3+totloc4

Place this in a report header section below the ones containing the subreports or in the report footer section.

-LB
 
Ibass/all,

Apprectiated your help it works!

I'm really happy now :)[peace] [thumbsup2]

Rgds,MHP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top