Print Page | Close Window

Conditional Subreports Based on Data Fields

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
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=4814
Printed Date: 18 Apr 2025 at 10:55pm


Topic: Conditional Subreports Based on Data Fields
Posted By: BernieHunt
Subject: Conditional Subreports Based on Data Fields
Date Posted: 16 Nov 2008 at 10:24pm

I have a current solution that received three tables, one is the parent table, one is the main set of child records, and the third is an optional set of child records. The third set prints as a subreport.

I would like to include a field in the parent table that indicates if the subreport should be printed or not. If the field is true, then the subreport prints. If the field is false, then a text string is printed instead and the space is conserved.

Is this possible and can you point me in the right direction?

I've read how to make the subreport option using a second copy if itself, but I'd like to make the report operation quicker by making the decision in code ahead of time. Also it didn't show how to replace the subreport with a text string.

Thanks,
Bernie

 




Replies:
Posted By: BrianBischof
Date Posted: 17 Nov 2008 at 10:05am
I've never done this before, but I think its not difficult. I would create two sections and put the subreport in the first section and your textbox in the second section. Then use the Suppress property for each section and create a conditional formula that tests the value of that field. Make the formula return True when you want  a section hidden and make it false when you want to display the section. Of course, the logic for the textbox will have to be the opposite of the logic of the subreport. That way, when one is being displayed, the other is being hidden.
 
I cover many subreport tips and tricks in Chapter 9 of my Crystal Reports Encyclopedia book. You can find out more about my books at http://www.amazon.com/exec/obidos/ASIN/0974953601/bischofsystem-20 - Amazon.com or reading the http://members.crystalreportsbook.com - Crystal Reports eBooks online.


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: BernieHunt
Date Posted: 18 Nov 2008 at 9:16pm
Thanks Brian!
 
I'll give that a try.
 
Question about your books; I have the Crystal Reports for .Net Programming and I love it!
 
Do I need both of the other books, Vol1, or Vol2?
 
It's time to make out my christmas list.
 
Bernie
 


Posted By: BrianBischof
Date Posted: 18 Nov 2008 at 10:23pm
Well, I would be delighted for you to get all my books! But you really don't need them....
 
Amazon just listed the CR.NET 2005/2008 book as being in stock today (finally!) and I'm very proud of it. There is some really cool stuff in Volume 2 that you can't find anywhere else (reporting off LINQ data sources and DLLs, writing UFLs, creating CR XI add-ons). Volume 1 is only necessary if you just have CR XI. I do have a great chapter on how to build financial reports and creating custom cross-tab objects, but unless you need that info, the book is very similar to Volume 2, but without the programming code.
 
-Brian


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>



Print Page | Close Window