Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 21st, 2008, 08:15 AM
Friend of Wrox
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default Passing parameter using VB 2005

I am trying to pass a parameter to crystal report from my vb windows application. The parameter is a time stamp.

Getting error:

quote:Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))

Line in error:

crParameterFieldLocation = crParameterFieldDefinitions.Item("StartDate")
Here is my code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim myCrystalReport1 As New ReportDocument

        myCrystalReport1.Load(Application.StartupPath + "\CrystalReport1.rpt")

        'Declare the parameter related objects.
        Dim crParameterDiscreteValue As ParameterDiscreteValue
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldLocation As ParameterFieldDefinition
        Dim crParameterValues As ParameterValues

        ' Get the report's parameters collection.
        crParameterFieldDefinitions = myCrystalReport1.DataDefinition.ParameterFields

        ' Set the first parameter
        ' - Get the parameter, tell it to use the current values vs default value.
        ' - Tell it the parameter contains 1 discrete value vs multiple values.
        ' - Set the parameter's value.
        ' - Add it and apply it.
        ' - Repeat these statements for each parameter.

        crParameterFieldLocation = crParameterFieldDefinitions.Item("StartDate")
        crParameterValues = crParameterFieldLocation.CurrentValues
        crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
        Dim strStartdate As String = "2008-15-05 23:30:00 AM"
        crParameterDiscreteValue.Value = strStartDate

        ' Set the Crytal Report Viewer control's source to the report document.
        CrystalReportViewer1.ReportSource = myCrystalReport1

    End Sub

Similar Threads
Thread Thread Starter Forum Replies Last Post
VB 2005 Parameter Query mrmarkt Visual Basic 2005 Basics 0 November 25th, 2007 11:31 AM
passing parameter sarah lee ASP.NET 1.0 and 1.1 Basics 3 September 5th, 2006 04:29 PM
passing parameter.. suzila VB.NET 2002/2003 Basics 7 May 17th, 2004 08:28 PM
Parameter passing psambor Beginning PHP 0 September 17th, 2003 01:47 AM
Passing Parameter tgopal Javascript 3 August 7th, 2003 07:54 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.