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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameters to Crystal Report

Status
Not open for further replies.

rushdib

Programmer
Jun 12, 2001
203
US
Hello,
I am new to VB.net. I like to know how do I pass parameters to run a report using Crystal Reports.

Thanks in advance,

Rushdi Basir
 
Hi rush,

Here i have mentioned just example. just look in to that. so that you can know how to pass the parameter to crystal report.

**********************************************
' Declare variables needed to pass the parameters
' to the viewer control.
Dim paramFields As New ParameterFields()
Dim paramField As New ParameterField()
Dim discreteVal As New ParameterDiscreteValue()
Dim rangeVal As New ParameterRangeValue()

' The first parameter is a discrete parameter with multiple values.

' Set the name of the parameter field, this must match a
' parameter in the report.
paramField.ParameterFieldName = "au_lname"

' Set the first discrete value and pass it to the parameter
discreteVal.Value = "Dull"
paramField.CurrentValues.Add(discreteVal)

' Set the second discrete value and pass it to the parameter.
' The discreteVal variable is set to new so the previous settings
' will not be overwritten.
discreteVal = New ParameterDiscreteValue()
discreteVal.Value = "kannan"
paramField.CurrentValues.Add(discreteVal)

' Add the parameter to the parameter fields collection.
paramFields.Add(paramField)

' The second parameter is a range value. The paramField variable
' is set to new so the previous settings will not be overwritten.
paramField = New ParameterField()

' Set the name of the parameter field, this must match a
' parameter in the report.
paramField.ParameterFieldName = "ZIP"

' Set the start and end values of the range and pass it to the 'parameter.
rangeVal.StartValue = 1
rangeVal.EndValue = 94618
paramField.CurrentValues.Add(rangeVal)

' Add the second parameter to the parameter fields collection.
paramFields.Add(paramField)

' Set the parameter fields collection into the viewer control.
CrystalReportViewer1.ParameterFieldInfo = paramFields

CrystalReportViewer1.ReportSource = "C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\WindowsApplication1\CrystalReport1.rpt"

*************************************************

you have to use namespace of Imports CrystalDecisions.Shared
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top