Change text object crystal report during run time with vb.net

0

I have problem with crystal report. This is the scenario.

I want to print to printer from vb.net --> crystal Report --> Printer.

There is one blank field called DOType. When i run the program, i want to print with 1 Original (blank field called DOType was changed into "ORIGINAL") and 2 copies (blank field called DOType was changed into "COPY")

Here is my code :

Dim cryRpt As New ReportDocument
    cryRpt.Load("RASManualDeliveryOrder.rpt")
    Dim crParameterDiscreteValue As ParameterDiscreteValue
    Dim crParameterFieldDefinitions As ParameterFieldDefinitions
    Dim crParameterFieldDefintion As ParameterFieldDefinition
    Dim crParameterValues As ParameterValues

    crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
    crParameterFieldDefintion = crParameterFieldDefinitions.Item("@DOType")
    crParameterValues = crParameterFieldDefintion.CurrentValues
    crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
    crParameterDiscreteValue.Value = "ORIGINAL"
    crParameterValues.Add(crParameterDiscreteValue)
    crParameterFieldDefintion.ApplyCurrentValues(crParameterValues)
    Form1.CrystalReportViewer1.ReportSource = cryRpt
    Form1.CrystalReportViewer1.Refresh()
    Form1.Show()

An error occured while in "crParameterFieldDefintion = crParameterFieldDefinitions.Item("@DOType")"

This the error shown : Invalid Index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)

Any idea ?

vb.net
visual-studio-2010
crystal-reports
crystal-reports-2010
asked on Stack Overflow Nov 5, 2014 by Leonard Febrianto • edited Nov 5, 2014 by Leonard Febrianto

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0