Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Subreport with parameter from parent Post Reply Post New Topic
Author Message
FourOaks
Newbie
Newbie
Avatar

Joined: 11 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote FourOaks Replybullet Topic: Subreport with parameter from parent
     Posted: 11 Aug 2009 at 5:09am
Hi,
 
I have joined the forum specifially because I am having a problem which I hope someone will enable me to overcome!  I have scanned the existing topics but not found one which answers my problem.
 
We am generating a number of reports from a VB Web application, most of which are working fine.
 
We are designing the reports in the CR 2008 environment, using SQL queries to source the database fields.  Then we programmatically load the main report SQL at run time in the VB using the ReportDocument DOM (because there are run-time changes we need to make to the query).  The 'spoof' SQL in the CR document, and the SQL loaded at run-time have exactly the same field names
 
One of the reports, however, needs a sub-report in the Details section which takes a parameter from one of the other fields in that section.  The sub-report SQL is fixed and therefore the query embedded in the CR document can be used.
 
In the CR environment the Preview is working with no problem, but when we generate the report from the VB, the sub-report is not populated.
 
I am guessing that it will be something to do with the sub-report 'Links', but have been unable to determine quite what!  Do I perhaps need to add a "TableLink" object at run-time to link the sub-report parameter to the main report field?  If so how?  If not what?
 
Many thanks in advance.
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 11 Aug 2009 at 6:20am
I would think that the report and the subreport are already linked if report works in the preview mode.  Since a subreport is independent, do you need to set it's database? Maybe verify the database.
 
I hypothesize as my data comes into the reports as an XML file, and if I needed a subreport with different sql, I would just bring in another table, and I wouldn't need to worry, but your case is slightly different.
IP IP Logged
FourOaks
Newbie
Newbie
Avatar

Joined: 11 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote FourOaks Replybullet Posted: 11 Aug 2009 at 6:44am
Thanks for the prompt (though not too encouraging!) response.
 
Not sure whether this is relevant, but if I watch the document after it has finished loading all it's stuff at run-time I have...
 
doc.Subreports.Item(n).Database.Links.Count = 0
 
(where "n" is such as to point at the subreport in question).
 
I would have expected this to contain details of the parameter link?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 11 Aug 2009 at 6:56am
It seems that this is where you would find link information.  It would seem that you need to create a new link to join main report and the subreport.
 
I don't know how to accomplish this, as I use ADO.Net for the connection, and the report just consumes the data that I feed it.
 
As long as the structure is the same, Crystal is happy...if anything changes, then things start to not work. I would have thought that Crystal would have behaved 'correctly', since you stated that the field names are the same. 
 
I haven't done too much interfacing with Crystal via the exposed methods, just setDataSource.
 
Sorry I can't be of more help.
IP IP Logged
FourOaks
Newbie
Newbie
Avatar

Joined: 11 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote FourOaks Replybullet Posted: 11 Aug 2009 at 7:01am
Ok, thanks anyway - I'll just keep my fingers crossed that someone else comes along who has met, and solved, my case!
 
Meanwhile I'll keep looking Confused
 
Argh! As far as I can see all the TableLinks properties are read only!  So if you can't set them at run-time the problem must be somewhere else.
 
Heeeeeeeeellllllllllllllpppppppppp!!


Edited by FourOaks - 11 Aug 2009 at 7:33am
IP IP Logged
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