|
-
Mar 31st, 2005, 11:25 AM
#1
Thread Starter
Addicted Member
passing paramter to CR subreport through VB.net
Hi all, I am having trouble passing parameter values to my Crystal Report 10 report through VB.NET 03. Below is the code I am using. It works fine for everything else (like the main report), EXCEPT when I have a subreport in my report that requires a parameter.
When going through VB I get a "The parameter is incorrect" error. After the error, in the crystal report viewer if you hit refresh then the Report will ask for the parameters and it will work then. Obviously, it has to do with passing the parameters to the subreport correctly through VB then?
Does anyone have some suggestions?
VB Code:
Dim oRpt As New ReportDocument
oRpt.Load("C:\Program Files\System2\rpts\ABSTL\rptTMreceipt.rpt")
Dim param1Fields As New CrystalDecisions.Shared.ParameterFields
Dim param2Field As New CrystalDecisions.Shared.ParameterField
Dim param2Range As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim param3Field As New CrystalDecisions.Shared.ParameterField
Dim param3Range As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim param4Field As New CrystalDecisions.Shared.ParameterField
Dim param4Range As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim param5Field As New CrystalDecisions.Shared.ParameterField
Dim param5Range As New CrystalDecisions.Shared.ParameterDiscreteValue
param2Field.ParameterFieldName = "@startdate"
param3Field.ParameterFieldName = "@tax" 'supreport parameter
param4Field.ParameterFieldName = "@markup" 'supreport parameter
param5Field.ParameterFieldName = "@EqMarkup" 'supreport parameter
param2Range.Value = startdate
param3Range.Value = F9.txtTMsalestax.Text
param4Range.Value = F9.txtTMmatmarkup.Text
param5Range.Value = F9.txtTMeqmarkup.Text
param2Field.CurrentValues.Add(param2Range)
param3Field.CurrentValues.Add(param3Range)
param4Field.CurrentValues.Add(param4Range)
param5Field.CurrentValues.Add(param5Range)
param1Fields.Add(param2Field)
param1Fields.Add(param3Field)
param1Fields.Add(param4Field)
param1Fields.Add(param5Field)
-
Mar 30th, 2007, 01:10 PM
#2
Hyperactive Member
Re: passing paramter to CR subreport through VB.net
I am not sure if you are still stuck on this one, but here is my code that works:
Code:
Dim pf As ParameterField = CrystalReportViewer1.ParameterFieldInfo(0)
Dim pfv As ParameterDiscreteValue = New ParameterDiscreteValue
Dim pf2 As ParameterField = CrystalReportViewer1.ParameterFieldInfo(1)
Dim pf2v As ParameterDiscreteValue = New ParameterDiscreteValue
Dim pf3 As ParameterField = CrystalReportViewer1.ParameterFieldInfo(2)
Dim pf3v As ParameterDiscreteValue = New ParameterDiscreteValue
pfv.Value = Form1.txtUserCode.Text
Select Case Form1.ToolStripComboBox1.Text
Case "Primary"
pf2v.Value = 1
pf3v.Value = 2
Case "Secondary"
pf2v.Value = 2
pf3v.Value = 3
Case "Tertiary"
pf2v.Value = 3
pf3v.Value = 0
Case Else
pf2v.Value = 1
pf3v.Value = 2
End Select
pf.CurrentValues.Add(pfv)
pf2.CurrentValues.Add(pf2v)
pf3.CurrentValues.Add(pf3v)
I use the embedded viewer, but it looks like you need to specify an index for each parameter field in your declaration.
To the world you may just be one person, but to this one person, you just might be the world.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|