Avatar of wiswalld
wiswalldFlag for United States of America

asked on 

Set crystal report discrete value

I am trying to set the discrete value for a report when I open the form. It seems to work ??? but I am prompted for the discrete value anyway

Private Sub frmScoreCard_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim report As New rptScoreCard
        Dim ds As New DataSet()
        ds.ReadXml("C:\DVADGOLF\tblPlayer.xml")
        report.SetDataSource(ds)
        report.SetParameterValue("Course", frmRounds.DataGridView1.CurrentRow.Cells("Course").Value)
        Me.CrystalReportViewer1.ReportSource = report

    End Sub



I also want to add a second discrete value to be passed to the report.
Visual Basic.NETCrystal Reports

Avatar of undefined
Last Comment
Mike McCracken
Avatar of Mike McCracken
Mike McCracken

There is a property (on the rpeort pbject I think) to enable parameter prompting.  You can set it to false and tghe prompt should go away.

mlmcc
Avatar of wiswalld
wiswalld
Flag of United States of America image

ASKER

I could not find any option to set that. I am using Crystal Reports for VS2005.

Have you seen this

http://forums.msdn.microsoft.com/en-US/vscrystalreports/thread/0eb90aba-b6b3-44de-baeb-b18dac036ca8/
I hadn't seen that.

Here is a walkthrough for VS2005.  I think it may show you how
http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf

mlmcc
Avatar of wiswalld
wiswalld
Flag of United States of America image

ASKER

I have managed to come up with the code bleow but cannot figure out how to add a second parameter. From my searching I found out that if prompted for a discrete value the code is wrong. I got this to work but I want to add a parameter.

Dim paramFields As New ParameterFields()
        Dim paramField As New ParameterField()
        Dim discreteVal As New ParameterDiscreteValue()
        paramField.ParameterFieldName = "Course2"
        discreteVal.Value = frmRounds.DataGridView1.CurrentRow.Cells("Course").Value
        paramField.CurrentValues.Add(discreteVal)
        paramField.DefaultValues.Add(discreteVal)
        paramFields.Add(paramField)
        Me.CrystalReportViewer1.ParameterFieldInfo = paramFields
Avatar of wiswalld
wiswalld
Flag of United States of America image

ASKER

The second value will be a date if that matters
Avatar of wiswalld
wiswalld
Flag of United States of America image

ASKER

Still prompted for a date

 Dim paramFields As New ParameterFields()
        Dim paramField As New ParameterField()
        Dim paramField2 As New ParameterField()
        Dim discreteVal As New ParameterDiscreteValue()
        Dim discreteVal2 As New ParameterDiscreteValue()
        paramField.ParameterFieldName = "Course2"
        paramField2.ParameterFieldName = "RoundDate1"
        discreteVal.Value = frmRounds.DataGridView1.CurrentRow.Cells("Course").Value
        discreteVal2.Value = frmRounds.DataGridView1.CurrentRow.Cells("RoundDate").Value
        paramField.CurrentValues.Add(discreteVal)
        paramField.DefaultValues.Add(discreteVal)
        paramField2.CurrentValues.Add(discreteVal2)
        paramField2.DefaultValues.Add(discreteVal2)
        paramFields.Add(paramField)
        Me.CrystalReportViewer1.ParameterFieldInfo = paramFields
Avatar of wiswalld
wiswalld
Flag of United States of America image

ASKER

Disregard I forgot the second to last line of code

  Dim paramFields As New ParameterFields()
        Dim paramField As New ParameterField()
        Dim paramField2 As New ParameterField()
        Dim discreteVal As New ParameterDiscreteValue()
        Dim discreteVal2 As New ParameterDiscreteValue()
        paramField.ParameterFieldName = "Course2"
        paramField2.ParameterFieldName = "RoundDate1"
        discreteVal.Value = frmRounds.DataGridView1.CurrentRow.Cells("Course").Value
        discreteVal2.Value = frmRounds.DataGridView1.CurrentRow.Cells("RoundDate").Value
        paramField.CurrentValues.Add(discreteVal)
        paramField.DefaultValues.Add(discreteVal)
        paramField2.CurrentValues.Add(discreteVal2)
        paramField2.DefaultValues.Add(discreteVal2)
        paramFields.Add(paramField)
        paramFields.Add(paramField2)      'this line
        Me.CrystalReportViewer1.ParameterFieldInfo = paramFields
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo