Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Switching Between main report and Subreport Post Reply Post New Topic
Author Message
moontide
Groupie
Groupie
Avatar

Joined: 23 Feb 2011
Online Status: Offline
Posts: 78
Quote moontide Replybullet Topic: Switching Between main report and Subreport
     Posted: 12 Oct 2011 at 5:14am
I have two reports. Both reports have a common Customer ID. report A has data of customers beloning to category 1 and report B has data for customers from Category 2. Now what the client wants is to enter a Customer ID when loading the report and if the ID is in Category 1 then display report A else if Customer ID is in Category 2 then display report B. I probably have to insert Report B as a subreport and Report A as the main report. Now, what formula will enable to either show report A or report B based on the parameter selection? Any ideas would be appreciated !!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Oct 2011 at 7:24am

this depends on if a customer can be in both categories. You description appears to indicate they are mutually exclusive. assuming so...

i would
-add in a main report a param of the customer id.
-add report_A as a subreport in main report report header A and link on param to subreport customerid
-add report_B as a subreport in main report report header B and link on param to subreport customerid
-in each subreport suppress sections using isnull(customerid)
-in the main report suppress blank subreports
-in the main report suppress all of the other sections


Edited by DBlank - 12 Oct 2011 at 7:25am
IP IP Logged
moontide
Groupie
Groupie
Avatar

Joined: 23 Feb 2011
Online Status: Offline
Posts: 78
Quote moontide Replybullet Posted: 12 Oct 2011 at 8:16am
Thanks. I will try this out.
IP IP Logged
moontide
Groupie
Groupie
Avatar

Joined: 23 Feb 2011
Online Status: Offline
Posts: 78
Quote moontide Replybullet Posted: 13 Oct 2011 at 5:29am
Ok...now I am a bit stuck now. If I suppress the subreports and suppress all the sections in the main report then what formula would I use to show either report_A or Report_B?
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Oct 2011 at 5:46am
suppress all of the sections in each subreport if the customerid is null.
then the subreport will suppress itself natureally based on the data in the subreport (based on the subreport link).
Therefore report A shows only when it is supposed to ( a matching reocrd was found) and report B shows only when it is suppoed to (when a matching record was found)
IP IP Logged
moontide
Groupie
Groupie
Avatar

Joined: 23 Feb 2011
Online Status: Offline
Posts: 78
Quote moontide Replybullet Posted: 14 Oct 2011 at 9:33am
Is it possible to pass a shared variable between subreport_A and subreport_B ? I want to see customerId from report_A on report_B just for comparison. I created a shared variable in subreport_A and placed it in the report footer and suppressed it. then I tried putting the shared variable in subreport_B, but it is not showing any value.
 
Subreport_A:
 
whileprintingrecords;
shared numbervar custID := {table.col}
 
Subreport_B:
 
whileprintingrecords;
shared numbervar custID;
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Oct 2011 at 3:37am
I beleive so but have not tried it... but the parameter you are using as the link should be the same for both so just use the param value. it would be easier
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