Ellis
Member
Hi,
Im trying to open a letter which is a crystal report. I need to pass the report parameters. However although the crystal report viewer recognises Ive passed 3 parameters, I still get the dialog box requesting me to "Enter Parameter Values", how do I prevent this and get the report to use the parameters Ive added?
Here is my code... (any help or advice would be much appreciated)
CR Variables
Dim crReportDocumentPath As String
Dim crParameterFields As ParameterFields
Dim crParameterField As ParameterField
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterValue As ParameterValue
Report Variables
Public sReference As String
Public iCustomer As Int16
Public iAddrType As Int16
Get full path of the report to open
crReportDocumentPath = "\\SERVER\Letters\Letter Template.rpt"
Create a new instance of a discrete parameter object to set the value for the parameter.
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = sReference
Define the parameter field to pass the parameter values to.
crParameterField = New ParameterField()
crParameterField.ParameterFieldName = "chrRef"
Pass the first value to the discrete parameter
crParameterField.CurrentValues.Add(crParameterDiscreteValue)
Destroy the current instance of the discrete value
crParameterDiscreteValue = Nothing
Create an instance of the parameter fields collection, and
pass the discrete parameter with the two discrete values to the
collection of parameter fields.
crParameterFields = New ParameterFields()
crParameterFields.Add(crParameterField)
Destroy the current instance of the parameter field
crParameterField = Nothing
Create a new instance of a discrete parameter object to set the
value for the parameter.
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = iCustomer
Define the parameter field to pass the parameter values to.
crParameterField = New ParameterField()
crParameterField.ParameterFieldName = "inyCustomer"
Pass the first value to the discrete parameter
crParameterField.CurrentValues.Add(crParameterDiscreteValue)
Destroy the current instance of the discrete value
crParameterDiscreteValue = Nothing
Add to collection of parameter fields
crParameterFields.Add(crParameterField)
Destroy the current instance of the parameter field
crParameterField = Nothing
Add to collection of parameter fields
crParameterFields.Add(crParameterField)
Destroy the current instance of the parameter field
crParameterField = Nothing
Create a new instance of a discrete parameter object to set the
value for the parameter.
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = iAddrType
Define the parameter field to pass the parameter values to.
crParameterField = New ParameterField()
crParameterField.ParameterFieldName = "inyAddrType"
Pass the first value to the discrete parameter
crParameterField.CurrentValues.Add(crParameterDiscreteValue)
Destroy the current instance of the discrete value
crParameterDiscreteValue = Nothing
Add to collection of parameter fields
crParameterFields.Add(crParameterField)
Destroy the current instance of the parameter field
crParameterField = Nothing
The collection of parameter fields must be set to the viewer
CrystalReportViewer1.ParameterFieldInfo = crParameterFields
Set the viewer to the report object to be previewed. This
must be done after the parameter information has been set.
CrystalReportViewer1.ReportSource = crReportDocumentPath
CrystalReportViewer1.ReportSource = crNewReport
CrystalReportViewer1.Zoom(1)
Im trying to open a letter which is a crystal report. I need to pass the report parameters. However although the crystal report viewer recognises Ive passed 3 parameters, I still get the dialog box requesting me to "Enter Parameter Values", how do I prevent this and get the report to use the parameters Ive added?
Here is my code... (any help or advice would be much appreciated)
CR Variables
Dim crReportDocumentPath As String
Dim crParameterFields As ParameterFields
Dim crParameterField As ParameterField
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterValue As ParameterValue
Report Variables
Public sReference As String
Public iCustomer As Int16
Public iAddrType As Int16
Get full path of the report to open
crReportDocumentPath = "\\SERVER\Letters\Letter Template.rpt"
Create a new instance of a discrete parameter object to set the value for the parameter.
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = sReference
Define the parameter field to pass the parameter values to.
crParameterField = New ParameterField()
crParameterField.ParameterFieldName = "chrRef"
Pass the first value to the discrete parameter
crParameterField.CurrentValues.Add(crParameterDiscreteValue)
Destroy the current instance of the discrete value
crParameterDiscreteValue = Nothing
Create an instance of the parameter fields collection, and
pass the discrete parameter with the two discrete values to the
collection of parameter fields.
crParameterFields = New ParameterFields()
crParameterFields.Add(crParameterField)
Destroy the current instance of the parameter field
crParameterField = Nothing
Create a new instance of a discrete parameter object to set the
value for the parameter.
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = iCustomer
Define the parameter field to pass the parameter values to.
crParameterField = New ParameterField()
crParameterField.ParameterFieldName = "inyCustomer"
Pass the first value to the discrete parameter
crParameterField.CurrentValues.Add(crParameterDiscreteValue)
Destroy the current instance of the discrete value
crParameterDiscreteValue = Nothing
Add to collection of parameter fields
crParameterFields.Add(crParameterField)
Destroy the current instance of the parameter field
crParameterField = Nothing
Add to collection of parameter fields
crParameterFields.Add(crParameterField)
Destroy the current instance of the parameter field
crParameterField = Nothing
Create a new instance of a discrete parameter object to set the
value for the parameter.
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = iAddrType
Define the parameter field to pass the parameter values to.
crParameterField = New ParameterField()
crParameterField.ParameterFieldName = "inyAddrType"
Pass the first value to the discrete parameter
crParameterField.CurrentValues.Add(crParameterDiscreteValue)
Destroy the current instance of the discrete value
crParameterDiscreteValue = Nothing
Add to collection of parameter fields
crParameterFields.Add(crParameterField)
Destroy the current instance of the parameter field
crParameterField = Nothing
The collection of parameter fields must be set to the viewer
CrystalReportViewer1.ParameterFieldInfo = crParameterFields
Set the viewer to the report object to be previewed. This
must be done after the parameter information has been set.
CrystalReportViewer1.ReportSource = crReportDocumentPath
CrystalReportViewer1.ReportSource = crNewReport
CrystalReportViewer1.Zoom(1)