Crystal Reports - passing parameters

Posted on 2005-04-21
Last Modified: 2008-01-09
I am writing a program that uses a control collection created dynamically depending on the report to be displayed. I have set the .Tag value to ParameterFieldDefinition.Name. The report that I am using to test the program has 'Division', 'Department', 'FromDate' and 'ToDate'. When I run the program as is (with the   'ParameterValues.Add(ParameterDescreteValue) commented out) the last parameter is prompted for ('ToDate'). If I uncomment the line I get a 'Invalid object type' message. Please help.

 Private Sub btnViewReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnViewReport.Click
        Dim MyReport As ReportDocument
        MyReport = MainForm.MyReport
        Dim control As Control
        Dim dtDate As Date
        Dim parameterFieldDefinitions As ParameterFieldDefinitions = MyReport.DataDefinition.ParameterFields
        Dim ParameterFieldDefinition As ParameterFieldDefinition
        Dim ParameterValues As New ParameterValues
        Dim ParameterDescreteValue As ParameterDiscreteValue
        Dim frmReportViewer As New frmReportViewer

        ProjectForms.ReportViewerForm = frmReportViewer
        MyReport.SetDatabaseLogon("REPORTS", "VbCrystal")

        For Each control In Controls
            If Not (control.Tag = "") Then
                ParameterFieldDefinition = MyReport.DataDefinition.ParameterFields.Item(control.Tag)
                ParameterDescreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
                If TypeOf control Is DateTimePicker Then
                    dtDate = Convert.ToDateTime(control.Text)
                    ParameterDescreteValue.Value = dtDate
                    ParameterDescreteValue.Value = control.Text
                End If
            End If

        ReportViewerForm.CrystalReportViewer1.ReportSource = MyReport

    End Sub
Question by:Iron01
    1 Comment
    LVL 100

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now