Symptom
How do I pass values to parameters in the main and subreport using a Report Designer Component (RDC) Active Server Pages (ASP) application?
Resolution
NOTE: Subreport-linking parameters do not need to be set if you are using Crystal Report 8.x.
In Crystal Reports 8.x RDC ASP applications, main report parameters must be set on the main report, and subreport parameters must be set on the subreport.
To pass values to parameters in the main and subreport, using the following sample code:
set ReportDatabase = Session("oRpt").Database
'Set the Table object and logon (1 table only)
set crdatabasetables = ReportDatabase.Tables
set crtable = crdatabasetables.Item(1)
crtable.SetLogonInfo "ODBCDSNname", "", cstr(userid), cstr(password)
'Create subreport database object, get table(s), login
set CRSubreports = session("oRpt").OpenSubReport("testsub.rpt")
set ReportDatabase2 = CRSubreports.Database
Set crdatabasetables2 = ReportDatabase2.tables
Set CRtable2 = crdatabasetables2.Item(1)
crtable2.SetLogonInfo "ODBCDSNname", "", cstr(userid), cstr(password)
'Get handles to two parameters in main report
set Session("ParamCollection") = Session("oRpt").Parameterfields
Set ThisParam1 = Session("ParamCollection").item(1)
Set ThisParam2 = Session("ParamCollection").item(2)
'Set values for the parameters
ThisParam1.SetCurrentValue cstr("paramvalue1"),12
ThisParam2.SetCurrentValue cstr("paramvalue2"),12
'Get handles to two parameters in SUB report
set Session("SubRptParamCollection") = CRSubreports.Parameterfields
Set ThisParam1 = Session("SubRptParamCollection").item(1)
Set ThisParam2 = Session("SubRptParamCollection").item(2)
'Set values for the parameters that were previously set in the main report.
ThisParam1.SetCurrentValue cstr("paramvalue4"),12
ThisParam2.SetCurrentValue cstr("paramvalue3"),12
See Also
For RDC ASP sample applications, please refer to the Downloads area of our web site.
RDC ASP sample applications:
- aspxmps8.exe (version 8)
- aspxmps85.exe (version 8.5)
- aspxmps9.exe (version 9)
- aspxmps10.exe (version 10)
Keywords
ASP WEB VERSION SUBREPORT PARAMETER STORED PROCEDURE PARAMETER Crystal Reports ASP Report Server Parameters Subreports , c2010043 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , Problem