Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing objects on report from code.

Status
Not open for further replies.

sodakotahusker

Programmer
Mar 15, 2001
601
0
0
I am working in DOT NET and wanted to insert a text box on the report which I will update with the appropriate text at run time. How do I reference that object??

I created an instance of the report
but when I type the object name dot I do not see my text box in the list of intellisense options.
 
I don't know about text boxes but if there is no other way you can easily work around it using Parametar or Formula field.

HTH
Marin
 
Surely someone on this board can help me. What the heck good is an object oriented environment if you can't access the objects??
I tried reportDef.Section1. but still don't see an object I placed in section 1. There's got to be some master object reference that all all objects to be seen??
 
I'm not sure if there is a good explanation anywhere online about the object model used to programmtically edit reports, I used Brian Bischof's Crystal Reports .Net Programming

this should get you started

Imports CrystalDecisions.CrystalReports.Engine

Sub EditTextBox

Dim ReportOBJ as ReportClass
Dim sectionObj As Section
Dim itemObj As ReportObject
Dim textobj As TextObject

ReportOBJ = New CompanyReport 'the name of the .rpt file

'Loop through the sections of the report
For Each sectionObj In reportObj.ReportDefinition.Sections
For Each itemObj In sectionObj.ReportObjects
'Test to see if this is the TextBox you want to edit by checking against the name you used for it in the designer, defaults to Text1, Text2 ect.
if itemObj.Name = "NameYouGaveTheFieldInTheDesigner" then
if itemObj.Kind is CrystalDecisions.[Shared].ReportObjectKind.TextObject then

textobj = CType(itemObj, TextObject)
textobj.Text = "Text you want it to have"

end if
end if
Next
Next

end sub
 
Thanks for the info. I am using the Crystal Viewer and it appears that the object model for that is not as robust.
I only needed one field - so I used the SummaryInfo.ReportComments built in field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top