Print Page | Close Window

supress dat on main report based on subreport data

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=17198
Printed Date: 28 Apr 2024 at 8:23pm


Topic: supress dat on main report based on subreport data
Posted By: jbalbo
Subject: supress dat on main report based on subreport data
Date Posted: 02 Aug 2012 at 8:28am
Hi,
 
I have a report pulling data from a subreport.
I want to supress the detail line if a value on the subreport is a certain value.
 
example
 
Joe Jones 1/1/2012  Yes
Bill Jones  1/1/2012 No
 
Whewre Yes/No is cioming from supreport
 
Lets say I want to surpress lines with subreport field = 'No'
 
Thanks IN Advance
 
Joe
 



Replies:
Posted By: DBlank
Date Posted: 02 Aug 2012 at 8:31am
you have to bring the value back into the main report as a shared variable
both the subreport and the variable need to be place it in a section above/prior to the section you want to suppress and you can then suppress the section using the shared variable result in the main report


Posted By: jbalbo
Date Posted: 02 Aug 2012 at 8:39am
thanks for getting back...
I read a bit about it , but not really sure how to do the shared variable..
Any example or pages you can point me to?
 
Thanks
Joe
 


Posted By: DBlank
Date Posted: 02 Aug 2012 at 9:08am
in the sub report you create a formula with a shared variable assigning the value you want to return
 
shared stringvar x;
x: = (your yes no value field here)
 
in the main report create another formula field and do the same thing but assign it as
 
shared stringvar x;
x:=x
 
this moves the value from teh sub report to the main report
you can now reference this formula field in a suppression statement
eg. @formula='Yes'
 
note that sub reports cannot be suppressed and still run.
there is a trick to this. Suppress all of the fields in the subreport, set the sub report to suppress when blank and then set the sectio it is on to suppress when blank. It still runs this way.


Posted By: jbalbo
Date Posted: 02 Aug 2012 at 9:14am
Thanks Im ging to try and Let u know how I do...
Really appreciate it...
 


Posted By: jbalbo
Date Posted: 02 Aug 2012 at 10:12am
Ok, so I have the shared variable on the sub and main report and the data is pulling over. I know you said to put it in the section above but it seems to be null its in the group header
The data I want to surpress is in the detail section
When I put it in the detail section it seems to keep the same value until the value on the subreport changes?
 
Thanks
 


Posted By: DBlank
Date Posted: 02 Aug 2012 at 10:22am
make a details A - put the sr in that
detailsB - pu the shared variable formula in that
make the rest of your regular report as detailsC


Posted By: DBlank
Date Posted: 02 Aug 2012 at 10:24am
Note you can replace your subreport in details C with the shared variable formula in the main report so you are not running the same sub report twice per record which will unnecessarily slow down your report


Posted By: jbalbo
Date Posted: 02 Aug 2012 at 11:03am
sorry to be a pain....
so, I think I almost have it...
 
Detail A I have the subreport
Detail B I have the formula for the main report(shared stringvar x;
x:=x
and I have detail b surpressed.
Detail C I have the data I want to show...
 
I went ahead and hide drill down ok in the subreport
 
but if I try to hide Detail A in the main, I loose my data
 
Thanks


Posted By: DBlank
Date Posted: 02 Aug 2012 at 11:08am
yep. The subreport will not run if it is suppressed (my original post warning).
if you have it working as desired,
suppress all of the fields in the subreport,
in the main report,
right click on the sub report and select Format Sub report
select the Subreport tab
mark 'suppress blank subreport' as true
in teh section expert (main report) mark details a section as suppress when blank.


Posted By: jbalbo
Date Posted: 02 Aug 2012 at 11:24am
DBLANK,
 
Thanks so much. I've learned alot today...
Not that I probably won't ask the same thing again...lol
 
But I'm pinning this thread up on the fridge!!!!!
 
 
Thanks again
 
Joe
 


Posted By: Margaret
Date Posted: 13 Dec 2012 at 1:35am

Hello.. I too am trying to suppress a detail line when there is specific data returned in a subreport. I have tried to follow the instructions posted here and my report does not cooperate. I can get the subreport data into main report with a shared stringvar but it seems to be copying in for every record despite me laying it out as indicated. How do I stop that from happening? Am using v8.5.

Thanks


-------------
Margaret


Posted By: DBlank
Date Posted: 13 Dec 2012 at 3:56am
CAn you explain more your set report set up?


Posted By: Margaret
Date Posted: 13 Dec 2012 at 6:22am
I have a report showing recently admitted patients (name, location, service, etc) and also whether a particular patient  has an attachment on their record. I pull the attachment information using a subreport. That attachment text starts with 'MED' therefore it displays when present.
I want a version of the report that will not include the records that have the subreport returning data so that staff can focus on those that are missing. In order to do that, I was trying to suppress or otherwise hide the details for the records showing data from the subreport.
Had got as far as creating a shared stringvar to bring the subreport info back to main report but cannot successfully produce report that will hide those records poperly. Hope that helps. Thanks!

-------------
Margaret


Posted By: DBlank
Date Posted: 13 Dec 2012 at 9:56am
I believe you need something likes this
http://crystalreportsbook.com/forum/forum_posts.asp?TID=18258 - http://crystalreportsbook.com/forum/forum_posts.asp?TID=18258
 



Print Page | Close Window