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

Shared Variable Formula question

Status
Not open for further replies.

bv0719

MIS
Dec 19, 2002
131
US
My report utilizes shared variables. The report displays all of the correct information on the main report from the shared variables that are on 2 subreports. In order to total the amounts from the shared variable I needed the formula listed below.

whileprintingrecords;
numbervar mtdsharedsum :={@SHARED};
numbervar Summtdsharedsum := mtdsharedsum+Summtdsharedsum

Here's the problem. On the subreport the {@shared} variable is calculated as follows...
Sum ({@NET}, {@CONVERT})

The {@convert} is key to the formula since I need to see the costs by each general ledger number. @convert is a formula used to display the department extension of my G.L. number.

When I run the report and use the select expert to select multiple @convert numbers (basically 2 or more GL Dept's) the mtdsharedsum (this is the name for the formula listed in the first example) returns a running total value for each departments amounts.

How can I add @convert to the formula so that when the report is run each department will display it's own vales and not add the previous departments totals?

Thanks,
Bill
 
define your formulas for @Net and @convert

One problem I do see is that you use "WhilePrintingRecords"
with formulas which use summary functions....this should not be done.

How are you passing the "shared" variables back to the main report??? remember the use of shared variables in the main report should be done in sections FOLLOWING that containing the subreport.

Jim Broadbent
 
Jim,

The @net formula is as follows:

if {GLHIST.PostType} = 1 then
{GLHIST.Amount} * (-1)
else
{GLHIST.Amount}

The @convert formual is as follows:
right(totext({GLHIST.GLNumber},4,""),4)

The @shared variable formula is as follows:
WhilePrintingrecords;
Shared numberVar mtd;
mtd:= Sum ({@NET}, {@CONVERT})

This formula returns the values based on the department selected in @convert.

There are two subreports that use this formula. The formula above is from @shared and lists month to date amounts. The other formula @shared2 is for year to date information.

These subreports are on the main report in the details A section. Here's a basic layout...
PH GLNum Title MTD MTD Budg Vari YTD YTBudg Vari Annual
GH1 Group #1 (@convert)
Da Subreport 1 and 2 are listed here but nothing displays since I shrunk the details.
Db GLNum Title @shared MTDAmt Vari @shared2 YTDAmt Vari
GF1 Group #1 mtdsharedsum (sum)MTDAmt mtdvarisum etc...
RF Grand total

I pass the subreports to the main report using this formula
whileprintingrecords;
Shared numberVar mtd
or
whileprintingrecords;
Shared numberVar ytd

The @mtdsharedsum, @mtdvarisum, @ytdshared2sum, and @ytdvarisum are the formulas that I need help with. They all use the same formula for the most part with some variation for the shared name. This is the formula used for the mtdsharedsum amount.

whileprintingrecords;
numbervar mtdsharedsum :={@SHARED};
numbervar Summtdsharedsum := mtdsharedsum+Summtdsharedsum

The problem is the amount that displays is like a runing total instead of displaying the amount for each department.

Let me know if you need further info.

Thanks,
Bill V
 
Missed a section...

Dc section includes this formula and variations.
whileprintingrecords;
numbervar mtdsharedsum :={@SHARED};
numbervar Summtdsharedsum := mtdsharedsum+Summtdsharedsum

This is neccessary to calculate a summary.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top