VBApprentice
Programmer
I need assistance in detemining the problem with this code. I am trying to pass two parameters to a crystal report. If I only pass the first one it works great. If I pass two the second parameter is inserted in both of the paramenters. I verified this by displaying the parameters themselves in the crystal report. I found this code on tek-tips but it is not working for me. What am I doing incorrectly..
The code is a follows:
Dim crpt As CrystalReport1
Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo
Dim paramFields As New ParameterFields()
Dim paramField1 As New ParameterField()
Dim paramField2 As New ParameterField()
Dim discreteVal As New ParameterDiscreteValue()
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
With paramField1
.ParameterFieldName = "BeginDate"
discreteVal.Value = CType(Session("BeginDate", date) 'txtBeginDate.txt
.CurrentValues.Add(discreteVal)
paramFields.Add(paramField1)
CrystalReportViewer1.ParameterFieldInfo = paramFields
End With
With paramField2
.ParameterFieldName = "EndDate"
discreteVal.Value = CType(Session("EndDate", date) 'txtEndDate.txt
.CurrentValues.Add(discreteVal)
paramFields.Add(paramField2)
CrystalReportViewer1.ParameterFieldInfo = paramFields
End With
All help is most appreciated.
Thanks.
The code is a follows:
Dim crpt As CrystalReport1
Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo
Dim paramFields As New ParameterFields()
Dim paramField1 As New ParameterField()
Dim paramField2 As New ParameterField()
Dim discreteVal As New ParameterDiscreteValue()
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
With paramField1
.ParameterFieldName = "BeginDate"
discreteVal.Value = CType(Session("BeginDate", date) 'txtBeginDate.txt
.CurrentValues.Add(discreteVal)
paramFields.Add(paramField1)
CrystalReportViewer1.ParameterFieldInfo = paramFields
End With
With paramField2
.ParameterFieldName = "EndDate"
discreteVal.Value = CType(Session("EndDate", date) 'txtEndDate.txt
.CurrentValues.Add(discreteVal)
paramFields.Add(paramField2)
CrystalReportViewer1.ParameterFieldInfo = paramFields
End With
All help is most appreciated.
Thanks.