Click here to Skip to main content
16,020,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to pas parameters into a subreport in crystal report. ATTENTION its a windosw appliacation.. My code so far looks like ( BUT when i start the application it still requires the paramters from the user.


VB
Dim r As New rptMain '--this is the crystal report (main)
          r.SetDataSource(dsMain.Tables(0))


          Dim rr As New rptSub '-- this is the subreport 
          r.Subreports(0).SetDataSource(dsDetal)

          CrystalReportViewer1.ReportSource = r
Posted

VB
Dim r As New rptMain '--this is the crystal report (main)
          r.SetDataSource(dsMain.Tables(0))


          Dim rr As New rptSub '-- this is the subreport
          r.Subreports(0).SetDataSource(dsDetal.Tables(0))

          CrystalReportViewer1.ReportSource = r


When a add .Tables(0) to the subreport it is ok... ---> This line r.Subreports(0).SetDataSource(dsDetal.Tables(0))
previously it was
r.Subreports(0).SetDataSource(dsDetal)
 
Share this answer
 
Rightfully so you did not pass any parameter to the subreport.
VB
Dim r As New rptMain '--this is the crystal report (main)
          r.SetDataSource(dsMain.Tables(0))


          Dim rr As New rptSub '-- this is the subreport
          r.Subreports(0).SetDataSource(dsDetal)
         
' Assuming your parameter is named p1 and you want to pass the value "hello" to it
' the parameter is named helloparameter
         Dim PFlds As New ParameterFields() 
         Dim PFld As New ParameterField("helloparameter") ' changed here
         Dim PVal As New ParameterDiscreteValue()
         PVal.Value = "hello"
         PFld.CurrentValues.Add(PVal) 
         PFlds.Add(PFld)
         CrystalReportViewer1.ReportSource = r
         CrystalReportViewer1.ParameterFieldsInfo = PFlds
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900