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

Get a value from subreport2 to subreport1 for calculations

Status
Not open for further replies.

antonx

Programmer
Nov 16, 2002
31
CA
Hi,

I have a main report with 2 subreports (sub1 and sub2). Both subreports are in the report footer in the main report. Sub1 is grouped by months of 2002 and sub2 is grouped by months of 2003.

I need the grouped amount of 2003 in sub2 to go to sub1 because in sub1 I will need to do a group division calculation. (sub2.amt/sub1.amt)*100.

I have searched and tried some examples from this site but I have had no luck.

I have CR 8.5 and fairly new to Crystal. Any ideas?

Thank you for your help.
 
If you need a value from sub2 to be passed to sub1, sub2 needs to run first. Insert an additional report footer section and move sub1 to the new section. Then you should be able to pass the value from sub1 to sub2 using shared variables.
 
Hi again,

It seems that the value from sub1 is not passed to sub2. Sub1 results in 0.

This is what is I have in sub1

@Pct_Actual_Of_Plan_sbr
whileprintingrecords;
shared numbervar Pct_Actual_Of_Plan3;
if Pct_Actual_Of_Plan3 = 0
then 0
else Sum ({@Curr_Year_Actual_Pol_Cnt}, {@Qtr_Desc}) / Pct_Actual_Of_Plan3;


This is what I have in sub2

@Pct_Actual_Of_Plan_sbr3
whileprintingrecords;
shared numbervar Pct_Actual_Of_Plan3 := Sum ({RTL_SALES_PLN.PLAN_SALES_COUNT}, {@Qtr_Desc});


 
You ignored the important element here, where is sub2 in relationships to sub1?

Try this experiement, place sub2 in the report header (NOT page header).

Place sub1 in the report footer (NOT Page Footer).

If sub2 has a value, sub1 will receive it.

This works for everybody, so don't start second guessing your formulas, check location and verify what is being returned in SUB2 before you assume that it isn't working.

Also describe your layout, sych as sub2 is in group header 1, and sub1 is in group footer 1 or whatever.

-k
 
I cannot put them in report headers because they both (sub1 and sub2) are grouped.

Sub1 is in a group header of a report and sub2 is also a group header in another report.

I need a value from sub2 in group header and pass it to sub1 to calculate an amount (2 fields, one from sub2 and the other from sub1) and store the result in the group header of 1.

It is a bit complicated.

Any ideas!

Thank you!
 
Sub1 is in a group header of a report and sub2 is also a group header in another report.


This is confusing....Are you trying to pass a value from one CR report to another??? or from one subreport in one section to another subreport but within the same main report?

If these are 2 separate main reports you cannot pass values between them.

If it is 2 subreports within one main report then to pass the shared variables properly...it has to be like this

Section1 Subreport 1
Section2 Subreport 2

Where Sections 1 & 2 can be anywhere except that Section 1 executes Subreport 1 first. The subreports MUST be in separate sections otherwise the number won't pass properly.

If this doesn't answer your question....layout your report for us....but don't just use a lot of words... a diagram works best.

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
if sub1 is in a different report from sub2 then they can't communicate.

subreports have to be in the same report.

Perhaps you've mistyped what you meant, but until you're willing to describe where these subreports are, doubt that anyone can help you.

-k
 
Even if they were in the same report, a single shared variable isn't going to pass a series of subtotals from one report to another. One subreport will run and complete before the other subreport is started. They do not run concurrently. So you would end up passing only the last value.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top