Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter Passing in Crystal

Status
Not open for further replies.

VBApprentice

Programmer
Oct 4, 2001
14
US
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.


 
I had to define different discrete value variables for each parameter do to get it to work. Why it works this way and not your way . . . good question. Hope this helps.

With parmDriver
.ParameterFieldName = "DriverParm"
discreteVal.Value = "12345"
.CurrentValues.Add(discreteVal)
paramFields.Add(parmDriver)
End With

With parmSettleNo
.ParameterFieldName = "SettleParm"
discreteVal2.Value = "67"
.CurrentValues.Add(discreteVal2)
paramFields.Add(parmSettleNo)
End With

crvSettled.ParameterFieldInfo = paramFields
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top