Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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)

Posted
I'm not familier with how you are doing this, but I have great success using datasets as reportsource passed at runtime for a variety of reports all taking diferent parameters
My website
Posted

Thanks for you quick reply hog.

 

I found out what I was doing wrong, my report variables where like the stored procedure it used variables, they were all preceeded with a '@' character. Doh!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...