Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: amend subreport at runtime Post Reply Post New Topic
Author Message
marcstrong
Newbie
Newbie


Joined: 08 Apr 2012
Online Status: Offline
Posts: 9
Quote marcstrong Replybullet Topic: amend subreport at runtime
    Posted: 04 Sep 2012 at 5:06pm
Hi guys

I'm trying to implement the following code from the crystal report book:

Dim myReport As New CrystalReport1
 Dim mySubReport As CystalDecisions.CrystalReports.Engine.ReportDocument
 Dim myReportObject As CrystalDecisions.CrystalReports.Engine.ReportObject
 Dim myTextObject As CrystalDecisions.CrystalReports.Engine.TextObject
 mySubReport = myReport.OpenSubreport("Sales Subreport")
 myReportObject =   MySubReport.ReportDefinition.ReportObjects.Item("Text3")
 myTextObject = CType(myReportObject, CrystalDecisions.CrystalReports.Engine.TextObject)
 myTextObject.ObjectFormat.EnableSuppress = True
 CrystalReportViewer1.ReportSource = myReport

However, I get the following error message:

"Object reference not set to an instance of an object"

relating to:

MySubReport.ReportDefinition.ReportObjects.Item("Text3")

Can anyone offer a way around this?


Thanks


IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 05 Sep 2012 at 4:12am

Try this:

 
1.  Create a parameter in the main report that will contain the text data.
 
2.  Create a parameter in the subreport for the text data.  Put this on the report in the place of your "Text3" block.
 
3.  In the subreport links, link from the parameter in the main report to the parameter in the subreport.
 
4.  Set the main report parameter in your code instead of trying to update the text block.
 
-Dell
IP IP Logged
marcstrong
Newbie
Newbie


Joined: 08 Apr 2012
Online Status: Offline
Posts: 9
Quote marcstrong Replybullet Posted: 05 Sep 2012 at 11:22am
Hi Dell

Thanks for response.

Could you provide some sample code to show how I can do this?

Kind regards

Marcus
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 06 Sep 2012 at 3:42am
There's documentation for setting parameters here:  http://bit.ly/OZsPa0
This is in the XI r2 documentation, which is better than the docs for the newer versions and still works.
 
-Dell
IP IP Logged
marcstrong
Newbie
Newbie


Joined: 08 Apr 2012
Online Status: Offline
Posts: 9
Quote marcstrong Replybullet Posted: 06 Sep 2012 at 6:59am
Hi Dell

I will check it out

Thanks for the support

Marcus
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.