Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using a main report parameter on a subreport in Crystal Reports Viewer

Posted on 2010-11-14
4
Medium Priority
?
523 Views
Last Modified: 2012-06-27
I'm using C# 4.0 to display a Crystal Reports Viewer report.

The CR report contains a subreport. I need to add a parameter MachineSN to the subreport.

I've added the parameter to the main report but I can't access it in the subreport. On the main report I can right-click on the subreport box and choose Change Subreport Links. If I select MachineSN, it wants to create a filter.

If I manually add a parameter MachineSN to the subreport, I'm prompted for it when the report runs.

So, how can I make MachineSN available on the subreport?
0
Comment
Question by:BlearyEye
  • 2
4 Comments
 
LVL 1

Author Comment

by:BlearyEye
ID: 34130597
I might add that I wan the parameter only to display on the subreport. It does not enter into any filtering of data.
0
 
LVL 77

Accepted Solution

by:
peter57r earned 2000 total points
ID: 34130600
If you just want to use the parameter value in expressions or formulas (but not as part of the 'link' ) then you can pass the value using a shared variable.

Declare the variable in the main report header and assign the parameter value to it and then you can pick it up in the subreport by  declaring it in any formula you want to use it.

Shared stringvar myvariable;
myvariable:={?myparam};
""
0
 
LVL 6

Expert Comment

by:nsonbaty
ID: 34130873
do you need to just show the MachineSN, in the subreport as text or your need to extract data related to this MachineSN.
0
 
LVL 1

Author Comment

by:BlearyEye
ID: 34132117
peter57r: that did the trick.

shared variables are tricky ... it took me a while to figure out that they have to appear on the main report somewhere in order to get initialized and show up on the subreport.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question