Passing Paramaters with VB to Crystal Reports
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Passing Paramaters with VB to Crystal Reports

  1. #1
    Join Date
    Apr 2011
    Posts
    2

    Passing Paramaters with VB to Crystal Reports

    Hi Guys,

    Im new to this forum, and I hope some one can help me.

    I have a situation where I need to programatically pass paramaters using VB through to my crystal report. I am using Visual Studio 2008 for my development.

    Everything is working fine, but when I run the report I get a "Value cannot be Null" error. this is in the Crystal Reports Rorm Viewer.

    My complete code is below.

    =========================


    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    Imports System.Data.OleDb

    Public Class Form1



    Private Sub CrystalReport11_InitReport(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReport11.InitReport



    Dim CR As New ReportDocument
    CR.Load("C:\VBScript\WindowsApplication1\CrystalReport1.rpt")


    Dim crParameterDiscreteValue As ParameterDiscreteValue

    Dim crParameterFieldDefinitions As ParameterFieldDefinitions

    Dim crParameterFieldLocation As ParameterFieldDefinition

    Dim crParameterValues As ParameterValues


    crParameterFieldDefinitions = CR.DataDefinition.ParameterFields



    crParameterFieldLocation = crParameterFieldDefinitions.Item("@ParameterName1")

    crParameterValues = crParameterFieldLocation.CurrentValues


    crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue


    crParameterDiscreteValue.Value = "test"


    crParameterValues.Add(crParameterDiscreteValue)


    crParameterFieldLocation.ApplyCurrentValues(crParameterValues)



    CrystalReportViewer1.ReportSource = CR




    End Sub


    End Class


    =========================


    As I said my paramater is passed and displayed on the report, but I keep getting this error...

    can anyone help.

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: Passing Paramaters with VB to Crystal Reports

    Fix your code. Add [] [/] with Code before the ]

    Code:
    ' This is code
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Apr 2011
    Posts
    2

    Re: Passing Paramaters with VB to Crystal Reports

    I dont understand fix your code?

    is it not readable?

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,091

    Re: Passing Paramaters with VB to Crystal Reports


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center