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!

shared Variables ?

Status
Not open for further replies.

johnism

Technical User
Jul 31, 2002
53
0
0
US
ok I have it sharing a variable but it seems to be only taking the last record and if I am wanting to do more one sum ( for example I have three groups and I am wanting to share the three different sums ) . This dosn't seem to work either. For each sum I created it's own shared variable which on the main report will be added together. For sum reason I am not sure this does not work.
 
main report
(
whileprintingrecords;
Shared numbervar Batch
)
subreport
(
whileprintingrecords;

Shared numbervar Batch :=Sum ({Tkbatch.Qty}, {Tkbatch.Qty})

)
This should return multiple sums , but it onl returns one value and that is the last sum?
 
That depends on where you place the subreport, if it's in a group footer of something, then every time it runs it will return a value.

I don't understand why you would be building a sum on {tkbatch.qty}, grouped by the same thing ({tkbatch.qty}), I didn't even think that was possible...

If you want to return these values at each iteration of some thing, such as {tkbatch.customername}, create a {tkbatch.customername} group in the main report and run the subreport in the group header or footer as appropriate.

OR

Create individual shared variables in the subreport for each condition, which would require previous knowledge of the possible types, and hardcode for each.

-k

kai@informeddatadecisions.com
 
I have tried that , sorry about the sum({Tkbatch.Qty}, {Tkbatch.Qty}) it was supose to be ({Tkbatch.Qty}, {Tkbatch.locationID}).
On the main I am grouping on location id and the subreport is in the header ( no luck ) same info no matter what location. Do the tables you use have to be exactly the same between the sub and main report ?


 
No, the tables don't have to be the same, but you must have a link between the two.

Are you resetting the shared variable?

The approach should be something like this:

GH1 Formula which resets the Shared Vairable
GH2 Subreport which sets the shared variable
Details
GF1 Display the shared variable

At each GF1 you'll get a new Shared Variable.

-k kai@informeddatadecisions.com
 
No, I am not resetting ( not sure how too , do you have an example ? )
I have the subreport on the header
so
Main report and sub are linked by laoction id

Gh1 location group with subreport
gh2 Product
detail
Gf2 Product
Gf1 Display shared variable

Thanks for the help,
John
 
No, I am not resetting ( not sure how too , do you have an example ? )
I have the subreport on the header
so
Main report and sub are linked by laoction id

Gh1 location group with subreport
gh2 Product
detail
Gf2 Product
Gf1 Display shared variable

Thanks for the help,
John
 
Are you trying to accumulate all the totals into one Batch total to add back into the main report? In that case do

Shared numbervar Batch := Batch +
Sum ({Tkbatch.Qty}, {Tkbatch.Qty})
In your subreport.

If you want three batch totals back in your main report, do
Shared numbervar Batch1;
Shared numbervar Batch2;
Shared numbervar Batch3;

If {table.group} = "Group1" then
Batch1 :=Sum ({Tkbatch.Qty}, {Tkbatch.Qty}) else
If {table.group} = "Group2" then
Batch2 :=Sum ({Tkbatch.Qty}, {Tkbatch.Qty}) else
If {table.group} = "Group3" then
Batch3 :=Sum ({Tkbatch.Qty}, {Tkbatch.Qty}) ;

The problem of course is what to do if the subreport has four groups, or more. A lot of groups require a different technique.

Treat the subreport as a stand alone summarised action in the main report. The subreport has to do ALL it's work, before it returns to the main report to continue processing. Then if the section is processed again, the subreport has to do it all again. You have to design your report on both levels: Main Report and Subreport.

Explain in more detail what they are both doing and what you really want the shared vairble to do.
Editor and Publisher of Crystal Clear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top