Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Suppress Master record if condition met on detail Post Reply Post New Topic
Author Message
RompinRonny
Newbie
Newbie


Joined: 26 Mar 2008
Location: Canada
Online Status: Offline
Posts: 8
Quote RompinRonny Replybullet Topic: Suppress Master record if condition met on detail
     Posted: 02 May 2008 at 8:48am

Hello all.  I have a system with a master client file and a treatment file where there can be one or more treatments per client (each treatment is a separate record in that file). 

If a specific treatment code is listed for a client, I want to exclude all treatment records as well as the master client record for that client.  I would also like to count the number of excluded master client records as well when I generate the report.  Do you have any suggestions on how I can achieve this?  I am using CR XI against an SQL database.
 
As always, thanks in advance for any suggestions or ideas you may have.
 
Regards,
Rompinronnny
In the beginning, the Universe was created. This made a lot of people angry, and has been widely regarded as a bad idea.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 02 May 2008 at 9:36am
I would create a conditional formula that returns True if a record has that treatment code. Then put this conditional formula in the group header and Details section for the Suppress property. That will suppress all records that relate to the one with this code.

To keep track of how many records this is, I would also create a Global variable that increments by one each time this happens and only include this in the conditional formula for the Details section. At the end of the report this variable should total the number of records that were skipped.

I cover how to write formulas and give numerous code samples for them in Chapters 5-7 of my Encyclopedia book. You can find out more about my books at Amazon.com or reading the 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>
IP IP Logged
RompinRonny
Newbie
Newbie


Joined: 26 Mar 2008
Location: Canada
Online Status: Offline
Posts: 8
Quote RompinRonny Replybullet Posted: 02 May 2008 at 11:16am
Hi Brian,

Thanks for the quick response.  Your solution works well for those detail records with the code I want to omit, but it still leaves the other detail records and the master record on the report.
 
Each detail record for a client is for a particular treatment.  If a client has the treatment code "HOM" , I want to suppress it, as well as suppress ALL other detail records for that client (those records will have treatments other than "HOM").  I would also like to suppress the corresponding Master file record for that client.
 
The Master file and the treatment (details) file are linked by the client number. 
I hope these additional details explain adequately what I am trying to do.
 
By the way, I do have a copy of the CR Encycopedia and I refer to it quite often, it is very helpful.
 
Again, any suggestions are greatly appreciated!
RompinRonny 
In the beginning, the Universe was created. This made a lot of people angry, and has been widely regarded as a bad idea.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 03 May 2008 at 2:14am
Thanks for getting the book! I'm glad you like it.

Well, what you are wanting to do is change a record based on a DIFFERENT record's value. That becomes much more difficult. In fact, I'm not sure how I would handle it. I think I would try to use a subreport to prior to printing out out the group header and in this subreport use a Shared variable to track if the particular group has a treatment code. If so, then all the sections in the main report will use that shared variable in a conditional formula to suppress the sections. Of course, you need to suppress all the subreport sections as well b/c you don't want to see any of that data, just use it for the formula.

It's a bit tricky, but I think this approach will work if you code your formulas carefully and debug them. See Tutorial 9-6 in the book for how to use subreports for hidden calculations and the following section for troubleshooting subreport shared variables.

You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.


Edited by BrianBischof - 03 May 2008 at 2:15am
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
RompinRonny
Newbie
Newbie


Joined: 26 Mar 2008
Location: Canada
Online Status: Offline
Posts: 8
Quote RompinRonny Replybullet Posted: 06 May 2008 at 6:05am
Hi Brian,
 
Thanks for the your reply.  I am doing as you have suggested and am almost there - I can get the shared variable passed to the main report, but am having trouble getting it to reset (I used the ideas from your book - very glad I bought it!)  I should have this problem resolved soon with some more trial and error (all part of the learning / "character building" associated with being a CR newbie....
Again, thanks for your assistance.
Regards,
RompinRonny
In the beginning, the Universe was created. This made a lot of people angry, and has been widely regarded as a bad idea.
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