Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: CR 2008 Loading subreports dynamically Post Reply Post New Topic
Author Message
elroydotnet
Newbie
Newbie
Avatar

Joined: 03 Feb 2009
Online Status: Offline
Posts: 8
Quote elroydotnet Replybullet Topic: CR 2008 Loading subreports dynamically
     Posted: 14 Jul 2011 at 9:04pm
Hi everyone
The scenario is that I have designed letterheads and footers as subreports for our different clients.
Based on a SQL query I would like to load the correct letterhead/footer within any given main report.
I'm using C#.net and CR2008 as follows:
myReport.SubReports["letterhead"].Load(getClientLetterHead(clientCode));
where getClientLetterHead is a simple function that returns the file path of the sub report as a letterhead based on the client.
Problem is when I run the code I get an error as follows:
NotSupportedException was unhandled by user code : Not supported within subreports.

I evaluate myReport.SubReports["letterhead"] and the object is not null.
Does anyone have any ideas?
The alternative would be to create a main report per client, which would make maintainance a nightmare.
Also having the letterhead/footer database driven wouldn't work well as the letterheads are vastly different.
Your help is always appreciated.
IP IP Logged
sreenu435
Newbie
Newbie


Joined: 15 Jul 2011
Online Status: Offline
Posts: 10
Quote sreenu435 Replybullet Posted: 15 Jul 2011 at 12:24am

Hi Create a parameter as a integer filed depends upon the client pass the parameter and suppress the sub reports which not required depend upon on the parameters and client

Example - client 1 - subreport1

                Client2- subreort2

 

for client1 pass the parameter as 1 suppress the subreport2 and do voice-versa for client

 

 
IP IP Logged
elroydotnet
Newbie
Newbie
Avatar

Joined: 03 Feb 2009
Online Status: Offline
Posts: 8
Quote elroydotnet Replybullet Posted: 15 Jul 2011 at 3:12am
I was hoping that I wouldn't have to do it like this, especially given that we have 50+ clients.
If I understand you correctly I would need to add 50+ sub reports to the main report? Surely this would increase the size of the main report substantially? and is it even possible?
IP IP Logged
CircleD
Senior Member
Senior Member
Avatar

Joined: 11 Mar 2011
Location: United States
Online Status: Offline
Posts: 251
Quote CircleD Replybullet Posted: 15 Jul 2011 at 1:58pm
You'll have a large formula but 50 subs aren't necessary.Something along the lines of:

If(?parameter) = First name then "First name" or
if(?parameter) = Second name then "Second name" or
etc.

If you wait a bit however one of the others will probably be along and can streamline it better than I can.
IP IP Logged
sreenu435
Newbie
Newbie


Joined: 15 Jul 2011
Online Status: Offline
Posts: 10
Quote sreenu435 Replybullet Posted: 20 Jul 2011 at 9:09pm

hi i hope this solution may useful for you. If you able to the save letterhead as a image call that image into the report using oledb object for each client you need to change the image. for all clients report will be same  but images will be changing for each client and the image you need to save same path  for all the clients

IP IP Logged
elroydotnet
Newbie
Newbie
Avatar

Joined: 03 Feb 2009
Online Status: Offline
Posts: 8
Quote elroydotnet Replybullet Posted: 20 Jul 2011 at 9:52pm
Thank you for your suggestion, definitely an alternative.
IMO still too much "working around" for a simple requirement.
What I have done in the mean time was combine all 50 clients letterheads into one report and hide their sections based on the client code, not the most elegant solution but again a work around.
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