Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppress Group Header if details are suppressed 1

Status
Not open for further replies.

aaronburro

Programmer
Jan 2, 2003
158
US
Please forgive me if this has been asked and answered before. I'm trying to suppress a group header and footer if all its subgroups and details are also suppressed.

My current workaround is just to create a faux header as a detail section and suppress it if it has already been printed, and not suppress it if "needs" to be printed and hasn't been yet. Needless to say, this solution is cumbersome to implement.

what is the general method for doing this without having to change the record selection formula?
 
Check Report > Selection Formulas > Groups. But it depends what your criterion is.

Note that summary totals are available in the Group Header and can be used for suppression etc. And that they include 'maximum', 'minimum' and 'distinct count'. You also have the first record in the group, and you can adjust the order within a group using sort criteria.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
What is your current suppression criteria for the subgroups and details?
 
well, the sample one I am doing is just a really simple one that is {SalesOrderShipTo.SalespersonCode} = "SD". I am well aware that in this case I should just use the record selection and filter out "SD", but the point of this sample is to teach me how to accomplish the premise without using the record selection formula. The reason is that I have a more complicated report on which I prefer to do said suppression, but the suppression of the details is done based on more complicated things than just a simple "exclude this salesperson" idea. Namely, I have to count the number of details, and then determine if it is necessary to show that result (ie, whether or not to suppress the detail section).
 
If you do a summary count of records in the group, you can use group suppress to suppress those that are less than a given number.

You should also be able to use this as a selection formula for a running total.

Right-click on a field and choose Insert to get a choice of Running Total or Summary. Or else use the Field Explorer, the icon that is a grid-like box, to add running totals.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Conditionally format your group using: Count({Your.Field}) > #, or relevant variant.

Naith
 
That should be Count({Your.Field},{Your.Group}) > #
 
If you do a summary count of records in the group, you can use group suppress to suppress those that are less than a given number.

I gave that a try, but the count always ended up counting the suppressed records/details anyway :(
 
Why are you supressing that group? You should exclude it from your report entirely with either a record or group selection formula.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
Why are you supressing that group? You should exclude it from your report entirely with either a record or group selection formula.

I am well aware that in this case I should just use the record selection and filter out "SD", but the point of this sample is to teach me how to accomplish the premise without using the record selection formula. The reason is that I have a more complicated report on which I prefer to do said suppression, but the suppression of the details is done based on more complicated things than just a simple "exclude this salesperson" idea. Namely, I have to count the number of details, and then determine if it is necessary to show that result (ie, whether or not to suppress the detail section).
 
Well, you already have one scenario where the records are conditionally suppressed correct? If so then use the same formula to conditionally supress the group header and footer.

As to the totals that are still being included, place the same logic ina formula to conditionally accumulate and sum the fields in question.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
Here's an idea:

What if I use the conditional logic that suppresses the various detail sections and use that to evaluate to a 1 or 0. 1 for show, 0 for suppress. Then I can do a summation on that value and if its zero, suppress. Will that work for suppressing the group header?
 
yeah, so that didn't work. 8.5 won't let me do a summary on a formula :(
 
Please post your formula. Crystal will let you summarize most formulas.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
The formula pretty much went like this:

if {CustomerMaster.SalespersonCode} = "SD" then 1 else 0

I clicked on the formula when it was placed in the report and then went to Insert|Summary but it was greyed out :/
 
I've used a 1 and 0 formula like this in a lot of reports and I'm not clear why it isn't working here.

Usually when I've seen this (inability to sum on a formula) it is because of an evaluation time issue. Are you sure you aren't trying to do a running sum instead of a sum? That could balk.

Look at evaluation time in your help file. I think the command you need to try is WhileReadingRecords; Make certain to include the semicolon or crystal won't recognize it as a separate statement. Put this in the line above like this:


WhileReadingRecords;
if {CustomerMaster.SalespersonCode} = "SD" then 1 else 0;


You'll also want to try the "WhilePrintingRecords" and "BeforeReadingRecords" statements until it either works or gives you an error message, which might tell us all something. If none of these change what is happening then let us know that too.

There is also a possibility that you are using the formula in another place that is inducing a specific evaluation time. At which point building a new formula that is exactly the same but only used in this one place might change the situation.

Since you are trying to learn more about this stuff, have a look at this link


Which has a nice diagram laying out what gets done and in what order.

Hope any of this helps.

Scott.
 
Welp, I tried it w/ the "whilereadingrecords" and it summed beautifully. Just for kicks, I also gave it a whirl w/ whileprintingrecords and that didn't allow me to do a summary. I could, however, change to whileprintingrecords after I had made the summary via readingrecords and it still worked. Haven't tried Beforerecords, but that is quite interesting. I'll go try and suppress on that, but it should work just fine.

thx!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top