Print Page | Close Window

Pass parameters from main report to subreport

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=21980
Printed Date: 28 Apr 2024 at 11:58am


Topic: Pass parameters from main report to subreport
Posted By: Radha
Subject: Pass parameters from main report to subreport
Date Posted: 24 May 2016 at 6:45pm
This is my table structure
OrderId        PurchaseDate
175,          '2016-03-28 00:00:00'
176,          '2016-04-01 00:00:00'
177,          '2016-04-04 00:00:00'
178,         '2016-04-05 00:00:00'
179,         '2016-04-06 00:00:00'
180,          '2016-04-13 00:00:00'
181,          '2016-04-18 00:00:00'
182,          '2016-04-22 00:00:00'
183,          '2016-04-26 00:00:00'
184,          '2016-04-29 00:00:00'
185,          '2016-04-30 00:00:00'

Another table

id    ProductName    qty     price OrderId

183, 'merchandise a', 25, 10, 175
184, 'merchandise a', 70, 10, 176
185, 'merchandise a', 40, 10, 177
186, 'merchandise a', 30, 11, 178
187, 'merchandise a', 50, 11, 179
188, 'merchandise a', 100, 11, 180
189, 'merchandise a', 125, 11, 181
190, 'merchandise a', 10, 11, 182
191, 'merchandise a', 200, 11, 183
192, 'merchandise a', 150, 9, 184
193, 'merchandise a', 120, 9, 185


I have a simple report with from date, to date, productname parameters showing 3  fields viz
ProductName, Qty(Sum of quantity), LastPurchaseDate(Max of purchase date)

Later I created a new column "View Chart". It is a subreport which links to another report which has a chart on it. Bascically when a user clicks on this link he should see the  points on the graph showing when the price has changed on a given product.

My question is how do I pass the above parameter values from code behind to this link chart i.e. when view chart is clicked?


p.s. I am using crystal reports for visual studio 2013 in vs2010 c# windows application




Replies:
Posted By: hilfy
Date Posted: 20 Jun 2016 at 4:18am
You don't have to do this in the code-behind. Try this:

1. Create an "On Demand" subreport in your main report to show your chart.

2. When you create the subreport, there is a "Links" tab you can use to set up the links from the main report. Or you can right-click on the subreport after you've created it and select "Change Subreport Links...".

3. Move the fields in the top left that you'll use to connect from your main report to the top right.

     a. If you're connecting to existing parameters in the subreport, turn off "Select data in subreport based on field" in the bottom right and select the subreport parameter to connect to in the bottom left.

    b. If you don't have existing parameters in the subreport, select the subreport field you want to link to in the bottom right.

-Dell

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window