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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

turn off grouping in a report dynamically

Status
Not open for further replies.

MrWombat

Programmer
May 14, 2003
4
AU
Hi there people
Just wondering how i could turn off and on grouping in a CR report dynaically. Basically i only want to create one report that will group the data if requested before hand or turns off the grouping. I have been told it has been done before in previous versions of crystal reports just wondering if it can be done with the .net version and how?
 
I don't know if this is the best way but I usually make a Parameter formula called, {SummaryOnly?}.

I make the default on this parameter "Yes" and "No".

I then design my reports to with the grouping and detailed looks I want. Then I suppress every section based on the value of {SummaryOnly?}.

For instance if you go into the formating of your details section you will see you can make a formula to supress it. Mine looks like this;

{SummaryOnly?} = "Yes"

If they choose "Yes" for the {SummaryOnly?} parameter then the details section will be supressed at runtime. Do the opposite formula for the groupings.

I hope this helps.
 
If you want to turn off or change the grouping (rather than suppress the grouping), create a formula to group on, and then based on a parameter, set the value, which can also be used for suppression of groups or details.

Here's an example:

If {?Groupingparm} = "Customer" then
{Table.customer}
else if {?Groupingparm} = "State" then
{table.state}
else
{table.detaillevelfield}

Now if you group on this, and they select anything other than Customer or State, it would default to the third choice, which should point to some details level field. Then you can suppress the group headers and footer if you like.

-k
 
Or as an alternative to SV's default choice

If {?Groupingparm} = "Customer" then
{Table.customer}
else if {?Groupingparm} = "State" then
{table.state}
else
"Other"

The only trick here is to make all results "String" results.

So if the user did not choose "Customer" or "State" then the report will group on a constant, (ie. "Other").... in other words it will not be grouped at all...You would then suppress the Group header and footer using similar logic.


Jim Broadbent
 
Thanks guys you have given me more than i asked for. Just a question for Jim and SV i understand the logic behind you statements and how they work but where do i put that code. Quote "Create a formula to group on" i know how to create a formula but how do i assign it to applt to grouping. Im not fully fluent with the formula editor.

Cheers Adam.
Didital Candy.. Your idea worked a treat also.
 
you just create a formula

@Group1 (or 2,3,4 whatever)

If {?Groupingparm} = "Customer" then
{Table.customer}
else if {?Groupingparm} = "State" then
{table.state}
else
"Other"

Now that the formula is created it is available for grouping since we haven't used "WhilePrintingRecords" in the formula

In the header and footer you would place something like the following formula in the conditional suppress of these sections

GroupName ({@Group1}) = "Other"



Jim Broadbent
 
Use Insert->Group and point at the formula.

Or if you have an existing group, right click it and select change group and select the formula.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top