Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: Conditional Subreports Based on Data Fields Post Reply Post New Topic
Author Message
BernieHunt
Newbie
Newbie


Joined: 03 Apr 2007
Location: United States
Online Status: Offline
Posts: 21
Quote BernieHunt Replybullet Topic: Conditional Subreports Based on Data Fields
    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

 

IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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 Amazon.com or reading the Crystal Reports eBooks online.


Edited by BrianBischof - 17 Nov 2008 at 10:06am
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>
IP IP Logged
BernieHunt
Newbie
Newbie


Joined: 03 Apr 2007
Location: United States
Online Status: Offline
Posts: 21
Quote BernieHunt Replybullet 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
 
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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


Edited by BrianBischof - 18 Nov 2008 at 10:24pm
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>
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.000 seconds.