Hi Andy,
I could not duplicate your code in a test app because I do not know what
'crystalcountsheets' is.
Let's see if I can help another way. Here's how I pass parameters to a
crystal report through vb .net:
Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim paramField2 As New ParameterField
Case "f:\imcapps\histdeff.rpt"
paramField.ParameterFieldName = "pstartbox" ' the name of one parameter in
the report
paramField2.ParameterFieldName = "pendbox" ' the name of one parameter in
the report
discreteVal.Value = Me.mmcomment1
discreteVal2.Value = Me.mmcomment2
paramField.CurrentValues.Add(discreteVal)
paramField2.CurrentValues.Add(discreteVal2)
paramFields.Add(paramField)
paramFields.Add(paramField2)
CrystalReportViewer1.ParameterFieldInfo = paramFields
connectionchange()
I first assign the two parameter names in the report to a parameterfield
variable. I then assign values to discreteval and discreteval2. I then
make those the currentvalues of the parameter variables; then they are added
to the parameterfields collection; finally, I add the parameterfields
collection to the viewer's parameterfieldinfo. Connectionchange() simply
changes pwds, logins, etc and run the report document object.
HTH,
Bernie
"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:e6*************@TK2MSFTNGP09.phx.gbl...
OK; I've got the code - I'll be out of town a few days but I'll take a
look at it when I return.
Bernie
"Oldhandandy" <Ol*********@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com... Hi Bernie
I have an opening form, the variable is populated by a combo box. I
produce
the report by pressing a button to open the CrystalReportViewer. The
report
is generated using a SQL Stored Procuedure.
Module module1
Public div As Integer
End Module
This is code I've input in the CrystalReportViewer
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Dim parameterfields As CrystalDecisions.Shared.ParameterFields
Dim parameterfield As CrystalDecisions.Shared.ParameterField
Dim spvalue As CrystalDecisions.Shared.ParameterDiscreteValue
parameterfields = New CrystalDecisions.Shared.ParameterFields
parameterfield = New CrystalDecisions.Shared.ParameterField
parameterfield.ParameterFieldName = "@div"
spvalue = New CrystalDecisions.Shared.ParameterDiscreteValue
spvalue.Value = div
parameterfield.CurrentValues.Add(spvalue)
parameterfields.Add(parameterfield)
CrystalCountSheets.ParameterFieldInfo = parameterfields
Andy
"Bernie Yaeger" wrote:
Hi Andy,
How are you defining the parameter that you are passing into the report?
Let us see the code.
Bernie Yaeger
"Oldhandandy" <Ol*********@discussions.microsoft.com> wrote in message
news:C5**********************************@microsof t.com...
> Since upgrading to .Net 2003, when I run report reports within an
> application
> using CrystalReportViewer, I'm getting the error "Specified Cast is
> not
> Valid". A value is being passed into the report.