Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Passing Shared values in detail section Post Reply Post New Topic
Author Message
fusion
Groupie
Groupie


Joined: 12 Nov 2007
Location: United States
Online Status: Offline
Posts: 93
Quote fusion Replybullet Topic: Passing Shared values in detail section
     Posted: 25 Apr 2008 at 11:37am
Is there a way I can pass the values in the subreport detail section to the detail section of the main report?
 
for example: In subreport details section I have
 
col1         Col2               col3
Matthew    20                $1000
Cathy        40                 $800
Tony          50                 $750
 
I need to pass these columns to the main report detail section. I have other columns in the subreport too but I want to pass these.
 
Any ideas if this is possible.
Thanks in advance
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 25 Apr 2008 at 4:32pm
Yes, you can pass data from the subreport to the main report. The key is that you have to create formulas that declare the variables as Shared. Second, the subreport has to appear in a section BEFORE the section that is sharing the data. The forces the subreport to execute prior the the place on the main report that is uses it.

I give complete coverage of subreports and tips and tricks for sharing data in Chapter 9 of my Encyclopedia. You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.

Edited by BrianBischof - 25 Apr 2008 at 4:33pm
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
fusion
Groupie
Groupie


Joined: 12 Nov 2007
Location: United States
Online Status: Offline
Posts: 93
Quote fusion Replybullet Posted: 25 Apr 2008 at 5:16pm

Brian,

Thank you for the reply. I am familiar with shared variable. But I never worked on a requirement where I had to pass all the values of subreport detail section to Main report detail section. I will also have to be able to use those values in further calculation.

I can have very few to hundreds of records. I need to be able to pass all those values. Someone told me that it is possible and suggested not to use it but did not tell me how.
 
 
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 26 Apr 2008 at 11:58am
The only way to do it is to use an array for each column in the subreport. That way the number of elements is dynamic and can match however many rows you have in the subreport.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
fusion
Groupie
Groupie


Joined: 12 Nov 2007
Location: United States
Online Status: Offline
Posts: 93
Quote fusion Replybullet Posted: 28 Apr 2008 at 8:47am
Brian,
Thank you for the reply. I tried to create a formula where I declare the column as an array and it gives me a message saying that the result of a formula can't be an array.
How can I do this?
 
Thanks
IP IP Logged
Seva
Newbie
Newbie
Avatar

Joined: 01 May 2008
Location: United States
Online Status: Offline
Posts: 10
Quote Seva Replybullet Posted: 02 May 2008 at 2:25pm
1.  Insert Section Below and switch them up -- I mean Detail Section in    Main Report
2. Place your Subreport in the new upper Detail Section of Main report.
3. You have to link Subreport to Main Report on the detail level
4. Pass your Shared to the Main Report.
5. Minimize Detail Section in Subreport and get your Shared Variable in Sub
out of Subreport canvas -- you can't suppress it, and you don't want to display it.
 
Thanks,
Seva
IP IP Logged
fusion
Groupie
Groupie


Joined: 12 Nov 2007
Location: United States
Online Status: Offline
Posts: 93
Quote fusion Replybullet Posted: 03 May 2008 at 12:19am
Seva,
Thank you for trying to answer my question.
for example: In sub report details section I have
 
col1         Col2               col3
Matthew    20                $1000
Cathy        40                 $800
Tony          50                 $750

I have a main report and it should get values for col4 and col5 from sub report
for the corresponding names.

Col1        col2     col3    col4   col5
Matt        axe      mgr    20     $1000
Cathy        car     gen   40      $800
Tony         toy     CIO    50      $750

How can I do this?



Edited by fusion - 03 May 2008 at 12:19am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 03 May 2008 at 1:48am
For the formula, you dont' want to return an array. Just return a dummy value that isn't used. You want to use the formula to declare a Global variable and share that with the main report. Then to display all the values on the main report, you will have to create a string that concatenates all the values together. If you need to have them all on a separate line then you can put a Chr(10) between each one for a carriage return (I think it's a 10, I forget right now...). That should do it.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
oscarfernandez
Newbie
Newbie


Joined: 07 Oct 2008
Online Status: Offline
Posts: 2
Quote oscarfernandez Replybullet Posted: 07 Oct 2008 at 12:31pm
Hi All- Apologies since I am new to this forum.  I have seen this post & others that describe how to use a shared variable so that you can display a value form a sub report in the main report.  However I have the same need of this posting to show the detail info from the sub report in the detail sections of the main report.  I followed the steps for the creation of shared variables (sub report in the header section & shared variable in the section below) but when displaying in the main report it only shows me the last value in my grouping. See my example below:
 
Subreport values:

Month

AvgPtsSeen

Jan

25

Feb

26

Mar

20

 
Main Report Vaues

Month

TotalPtsSeenDr

Jan

17

Feb

16

Mar

18

 
Current Result:

Month

TotalPtsSeenDr

AvgPtsSeen

Jan

17

20

Feb

16

20

Mar

18

20

 
Desired Result:

Month

TotalPtsSeenDr

AvgPtsSeen

Jan

17

25

Feb

16

26

Mar

18

20

 
Any help would be greatly appreciated.
 
-Oscar
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum