Data Connectivity
 Crystal Reports Forum : Crystal Reports .NET 2003 : Data Connectivity
Message Icon Topic: Passing Parameters to a Sub Report Programatically Post Reply Post New Topic
Author Message
Dilip Nagle
Newbie
Newbie
Avatar

Joined: 23 Nov 2006
Location: India
Online Status: Offline
Posts: 8
Quote Dilip Nagle Replybullet Topic: Passing Parameters to a Sub Report Programatically
    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')

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
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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 Amazon.com or reading the 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>
IP IP Logged
Dilip Nagle
Newbie
Newbie
Avatar

Joined: 23 Nov 2006
Location: India
Online Status: Offline
Posts: 8
Quote Dilip Nagle Replybullet 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
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.