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!

How to Share Subreport Data with the Main Report

Status
Not open for further replies.

etrain

Programmer
Aug 3, 2001
65
0
0
US
This Subject may look familar and that is becuase it is the same subject line of something in the Crystal Knowledge Base. It however does not answer the questions to my problem.

I have a main with 7 subreports. There is grouping done on the main report and via the subreport links my detail from the subreports group just fine.
Here is the problem. I have some subtotals that come at the end of the subreports. What I need is to get this subtotal on to the main report so I can plot them in a summary section of the main report.

I have used the Shared Variables and all is well except for the groups. Example, say my subreports are called 'A','B','C', and 'D'. If in the first grouping on the main report, only subreports 'A' & 'C' have data. The summary page displays the summary correctly. If the next grouping only has data in subreport 'A' then the summary shows the correct values for subreport 'A' but it also shows values from subreport 'C', where there is no data.

It is like if the previous grouping has data in a subreport and the subsequent subreports don't, the shared variable retains the previous value when it should be NULL and it is carrying foward. If the subsequent subreports do have data then the variable value does change to the correct amount.

I hope I make sense. I am pretty new to Crystal so I have not got a grasp over Shared Variables and how the reports processes.

In MS Access which is what the report was originally converted from it worked just fine. But in Access you could refererence the subreport object then reference the field in the subreport. It was real easy and you did not have to worry about what section came first or what ever. Remember the Past, Plan for the Future, yet Live in the Present for tomorrow may never come.
-etrain
 
You've answered your own question:

"the shared variable retains the previous value when it should be NULL and it is carrying foward"

Reset the shared variables (in the main report) to 0 prior to executing the subreports.
That way they are still 0 if the sub returns no data.

-k kai@informeddatadecisions.com
 
Ok so when you say "...prior to executing the subreports." What, where or when is prior? I put it in just about every place in the main report possible and nothing works.

Maybe I just don't understand the syntax or something. Here is what is on the subreport:
Shared stringVar ModName := {ITEM_TYPE};
This is what I put this in a formula field on the main report:
Shared stringVar ModName := ModName;
This is what I added as you suggested:
Shared stringVar ModName := "";

I have changed the second to
Shared stringVar ModName;
ModName;
As well and that doesn't work.

I went ahead and tested by removing all group sections except one, moved the subreports from the group sections to the details section and this worked. The subreports overlap and is a mess now but the variable is acting correct.
Would putting these subreports be in the Group Footer solve it? Or do they need to be in the details? I will try as I await a response. Remember the Past, Plan for the Future, yet Live in the Present for tomorrow may never come.
-etrain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top