hello,
i am trying to enter the form textbox.text in my crystal report, but getting error. code is

Dim RptForm As CrystalDecisions.CrystalReports.Engine.ReportDocument
    Dim T As CrystalDecisions.CrystalReports.Engine.TextObject
    RptForm = New CRrollnumberba1
    T = RptForm.ReportDefinition.Sections(0).ReportObjects("?SUBJECTNAME")
    T.Text = txtsubject.Text

the error showing "Index was outside the bounds of the array." at 4th line. and when i change the name of crystal report textbox name

Dim RptForm As CrystalDecisions.CrystalReports.Engine.ReportDocument
    Dim T As CrystalDecisions.CrystalReports.Engine.TextObject
    RptForm = New CRrollnumberba1
    T = RptForm.ReportDefinition.Sections(0).ReportObjects("SUBJECTNAME")
    T.Text = txtsubject.Text

i am getting error-Unable to cast object of type 'CrystalDecisions.CrystalReports.Engine.FieldObject' to type 'CrystalDecisions.CrystalReports.Engine.TextObject.please help me for this.............

Create a parameter in your crystalreport then transfer your value into the parameter.

        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue

        crParameterDiscreteValue.Value = Textbox1.text
        crParameterFieldDefinitions = CrystalReport1.DataDefinition.ParameterFields() 
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("Name of Parameter")
        crParameterValues = crParameterFieldDefinition.CurrentValues
        crParameterValues.Clear()
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.