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

Pass a value from subreport to main

Status
Not open for further replies.

aelsn

Technical User
Dec 17, 2004
17
0
0
US
Crystal 9

I am trying to use a total from a subreport in my main report and I'm not sure I'm on the right track. My main report has two groups: Salesperson and Account. My subreport (using a differnt historical table) is grouped the same way.

Main report:

GH1: Salesperson name
GH2: Account Number
Detals is suppressed
GF2: contains running totals pertaining to acct
GF1: Suppressed

subreport:

GH1: Salesperson
GH2: Account
Details is suppressed
GF2: contains summary total of commission ($ number)
GF1: suppressed

What I would like to do is use the commission summary total in the GF2 of my main report. I tried linking the two tables on account number and the many to many relationship doesn't work. Is there a way to use a shared variable to pass that commish value to the main report? If so, where do I place the formulas in each report and where do I insert the supreport in my main report? I imagine the subreport can be linked on account number. I've been digging around the various threads and can't seem to answer my question.

Thank you
 
You need to link the sub to the main report on both the salesperson field and the account field. The subreport should be placed in the Group Header #2 section or in a group footer section_a, above the section GF_b, where you would be using the figures.

In the sub you would then create a formula like this and place it it in the subreport report footer:

whileprintingrecords;
shared currencyvar com := sum({table.commission});

Then in GF_b, add a formula like this:

whileprintingrecords;
shared currencyvar com;

If you want, you can do a calculation in the formula:
whileprintingrecords;
shared currencyvar com;
sum({table.sales},{table.acct})+com

You should add a reset formula in GF_c:

whileprintingrecords;
shared currencyvar com := 0;

To make the subreport disappear, suppress all sections WITHIN the sub, format the subreprot (format subreport->subreport tab) to "suppress blank subreport" and in the section expert of the main report, check "suppress blank section". You might have to remove the sub border. What you cannot do is directly suppress the subreport or the section containing it.

-LB
 
Got it...looks great. Thanks so much.
 
LB,

My report is working as expected but I have one more question. My end users are interested in cases where the commissions charged over a certain timeframe are greater than 3% of the account value. I created a formula {@percent charged} consisting of {@com total} % {@Total Acct Value} and placed it in GF2. The {@com total} formula is the value passed from my subreport. I connditionally suppressed GF2 where {@percent charged} < 3. I checked Suppress Blank Section but the report is now showing blank lines where that section is suppressed. Is there way to accomplish this without the blank lines?

Thanks again.
 
Never mind, you already gave me the answer. When I clicked "suppress blank section" for the section containing my subreport, that seemed to eliminate my blanks. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top