Skip to Content
0
Former Member
Jul 08, 2014 at 05:51 AM

Pass more than two parameters to Crystal Reports from VB.NET

1059 Views

Below is my code in VB.NET 2010 to pass parameters in Crystal Report.

All the way I am able to pass one parameter in report which is packing_size (I have created packing_size field in Crystal Reports Parameter Fields)

Now I want to pass a second parameter with AND or OR condition.

Can I get help?

I have come all the way at 99% I want to complete it @100%, PLEASE HELP

Code as below:

Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class frmrptProducts
Private Sub frmrptProducts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim cryRpt As New ReportDocument
Dim CrTables As Tables
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo

'load report
cryRpt.Load(ReportPath & "CRproducts.rpt")

'Connection
With crConnectionInfo
.ServerName = My.Application.Info.DirectoryPath.ToString() & "\data\db.mdb"
'.DatabaseName = ""
'.UserID = ""
.Password = ""
End With

'Passing parameters code starts here
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue

crParameterDiscreteValue.Value = "200"
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("packing_size")'
crParameterValues = crParameterFieldDefinition.CurrentValues

crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
'Passing parameters code ends here

CRV.ReportSource = cryRpt
CRV.Refresh()

'Catch ex As Exception
' MsgBox(ex.Message)
'End Try

End Sub

End Class