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!

Problems with Shared Formulas on Groups... 1

Status
Not open for further replies.

kagee

Programmer
Apr 21, 2004
30
NL
Hi

Crystal Version: 10
Database: SQL Server.

Am having a problem with my shared CurrencyVar Formulas.

I have a main report, which summarises values from 7 subreports. The subreports pass data using shared CurrencyVar formulas.

The sum of each group in the subreport is meant to be passed as a value to the main report. If the group has no entries, then pass ZERO.

My subreport formula (using IFF) are as follows:

WhilePrintingRecords;
IIF (GroupName({table.accountDesc})= 'Travelling', Shared CurrencyVar FINTravel := (Sum ({table.Amount},{table.accountDesc})), 0)

WhilePrintingRecords;
IIF (GroupName({table.accountDesc})= 'Entertainment', Shared CurrencyVar FINEntertain := (Sum ({table.Amount},{table.accountDesc})), 0)

WhilePrintingRecords;
IIF (GroupName({table.accountDesc})= 'Residence', Shared CurrencyVar FINReside := (Sum ({table.Amount},{table.accountDesc})), 0)

etc

I have as many shared formulas as the Number of groups in each subreport

Problem at hand:
The formulas are only passing the value of the last group.
when i view the formulas in subreports they are oK, but when i pass it to the main report, only the value of last group is passed e.g if in the subreport residence is the last group, all values passed will = value of residence

Thus in main report ...

WhilePrintingRecords;
Shared CurrencyVar FINTravel

WhilePrintingRecords;
Shared CurrencyVar FINEntertain

WhilePrintingRecords;
Shared CurrencyVar FINResidence

Travelling Costs 10,000 (incorrect)
Entertainment 10,000 (incorrect)
Residence costs 10,000 (correct)

Please assist!
 
I would change the subreport formulas to:

//{@travel}:
if {table.accountDesc}= 'Travelling' then {table.Amount}

//{@entertain}
if {table.accountDesc}= 'Entertainment' then {table.Amount}

Repeat for "Residence"

Then create shared variables like the following to be placed in the subreport footer:

//{@shvartrav}:
whileprintingrecords;
shared currencyvar travel := sum({@travel});

//{@shvarent}:
whileprintingrecords;
shared currencyvar entertainment := sum({@travel});

//etc.

-LB
 
Thanks -LB,

I got it working by changing to the following (based on your ideas)
My Sub-reports formulas are:

Code:
//for travel
IF (GroupName({table.accountDesc})= 'Travelling')
then
Shared CurrencyVar FINTravel := (Sum({table.Amount},{table.accountDesc}))

//for Entertainment
IF (GroupName({table.accountDesc})= 'Entertainment)
then
Shared CurrencyVar FINEntertain := (Sum({table.Amount},{table.accountDesc}))

//for Residence
IF (GroupName({table.accountDesc})= 'Residence')
then
Shared CurrencyVar FINResidence := (Sum({table.Amount},{table.accountDesc}))

Then I maintained the main report's formulas as (placed in its footer sections):

Code:
WhilePrintingRecords;
Shared CurrencyVar FINTravel

WhilePrintingRecords;
Shared CurrencyVar FINEntertain

WhilePrintingRecords;
Shared CurrencyVar FINResidence

Now it works ... thanks!

KaGee!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top