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!

Passing data from formula fields in subreport to main

Status
Not open for further replies.

mobile2

Programmer
Dec 19, 2002
38
0
0
GB
Hi

I would like to provide text comments of what results appear in subreports.

Here is a sample of what's in the subreports (there are 2 subreports in each of the 7 main reports that are run weekly). I've cut down the amount of data I've shown in my samples to keep things simple.

Group
Name Formula Fields within Group Header(Current, Prev..)

Area Current Previous Change %
Edin £144,630 £131,438 £13,193 10%
Glas £133,514 £123,171 £10,343 8%
Aber £112,410 £108,941 £3,470 3%

Group
Footer
Total Formula fields within Group Footer

Scot £156,473 £150,330 £6,143 4%

Here is a sample of the text box which is currently placed in the main report and re-typed manually according to the results every time they are run.

Edin saw the largest increase with a 10% rise to £144,630
Aber say the largest decrease with a 3% drop to £133,514
The Scot average has increased by 4% to £156,473

I've looked over the FAQs and searched some answers on how to pass data from sub-report to main reports and think I will need to use shared variables which I haven't used before.

It would be great if you could get me started on how to display a text comment on the Scot (Total) which is always the same in our 7 main reports and would save a lot of typing. As regarding the increases/decreases which will change I'm not sure if this is possible.

Any advice greatly appreciated.

Thanks

Lyn
 
Lyn,
On the subreport, you are going to create a formula field for a shared variable. It's going to looks something like this:
(this is for a numeric shared variable)

whileprintingrecords;
shared numbervar ProdTons1;
ProdTons1 := Sum ({@Prod Tons Year1}, {Inhist.ProductID});

and on your main report you are going to create a formula field that will receive the shared amount :

whileprintingrecords;
shared numbervar ProdTons1;

if you are sharing an alphanumeric value, then it would be a shared varchar. You also must re-initialize the variable be reusing it. I usually do this in the level header. The syntax for that would be:

whileprintingrecords;
shared numbervar ProdTons1;
ProdTons1 := 0;

It's really very easy.
Cathy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top