Change text on crystal report


I have a crystal report that have text fields , which I want to change thier text inside the code.

Dim MyReport As New CashierClosedByCashierClosedIDRPT
MyReport.Section2.ReportObjects.Item("ClosedDate").text= SomeThing

but error come up like this
Error      7      'text' is not a member of 'CrystalDecisions.CrystalReports.Engine.ReportObject'.      

Who is Participating?
Mohamed AbowardaConnect With a Mentor Software EngineerCommented:
Add the function SetCRText(), and then use the following code:

SetCRText("ClosedDate", "Enter your text here", MyReport)
Private Sub SetCRText(ByVal FieldName As String, ByVal Value As String, ByVal Report As CrystalDecisions.CrystalReports.Engine.ReportDocument)
        Dim cReportTextField As CrystalDecisions.CrystalReports.Engine.TextObject = CType(Report.ReportDefinition.ReportObjects.Item(FieldName), CrystalDecisions.CrystalReports.Engine.TextObject)
        cReportTextField.Text = Value
    End Sub

Open in new window

Is the field a text or  database field?

I think you can just change it

MyReport.Section2.ReportObjects.Item("ClosedDate")= "SomeThing "

What version of Crystal?
Ahmadal_najjar2003Author Commented:
FIrst it is a text not a database field

Second I tried your code but give error :

Error      7      Property 'Item' is 'ReadOnly'.      
Another option is to pass parameters to the report and use as text.
Ahmadal_najjar2003Author Commented:
That's  really bery nice function

Thank you vey much
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.