Print Page | Close Window

Passing Parameters to a Sub Report Programatically

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
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=2918
Printed Date: 30 Apr 2024 at 7:23am


Topic: Passing Parameters to a Sub Report Programatically
Posted By: Dilip Nagle
Subject: Passing Parameters to a Sub Report Programatically
Date Posted: 14 Apr 2008 at 9:09pm

Background:

1. I have a Main Report whose Data source is a Stoted Procedure with two input Parameters @P_FINYEAR and @P_DEPT. These are shown by CR in Parameter List.

2. I have a sub-report(embeded in Main Report), whose data source is also a Stored Procedure with two input Parameters @P_FINYEAR and @P_DEPT . These are also shown in parameter list of SubReport.

3. The Main and sub Reports are linked based on two Fields of the Datasource viz. FINYEAR and DEPT.

4. I have been passing parameters to Main Reports as follows:

ocrListTax = New crListTax (which is class for my rpt file)

ocrListTax.SetDatabaseLogon('abc','pqr','NS-01','nsdb')

mailto:ocrListTax.SetParameterValue@P_FINYEAR - ", intFinYear)

ocrListTax.SetParameterValue("@P_DEPT", strDept)

ocrListTax.ExportToDisk(ExportFormatType.PortableDocFormat, 'd:FinTax.pdf')

ocrListTax.Close()

 
The Problem
 
1. How do I pass parameters to the sub report programatically?
 
Regards,
 
Dilip Nagle


-------------
Dilip Nagle



Replies:
Posted By: BrianBischof
Date Posted: 17 Apr 2008 at 1:26am
I have this documented in Chapter 17 of my CR.NET book. You do everything with subreports the same as the main report. However you FIRST have to reference the subreport directly using a ReportDocument object and calling the OpenSubreport() method. Here is pseudo-code.
DIM mySubReport as ReportDocument
mySubreport = myMainReport.OpenSubreport("subreport name")
mySubreport.SetParameterValue(....)

You can find out more about my books at http://www.amazon.com/exec/obidos/ASIN/0974953601/bischofsystem-20 - Amazon.com or reading the http://members.crystalreportsbook.com - Crystal Reports eBooks online.


-------------
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>


Posted By: Dilip Nagle
Date Posted: 18 Apr 2008 at 11:23am
Dear Brian,
 
Thanks for your solution about passing parameters to sub-Report.
 
I want to subscribe to your on-line books offer.
I just want to know if after subscrition, can I downloads these books viz. the Encyclopedia Vol 1 & 2 and CR.Net?
 
or do I have to purchase Paper Back edition?
 
Kindly advice.
 
Once again Many Thanks.
 
Dilip Nagle


-------------
Dilip Nagle



Print Page | Close Window