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

Dynamic Grouping 1

Status
Not open for further replies.

vishalsethia

Programmer
Nov 1, 2005
9
US
Hi,
I am using Visual Studio 2003 along with the Crystal reports bundle.

I waned to do a dynamic grouping on the fields based on what user selects.

I basically have 4 levels of grouping . Based on Department name, Class Rank, Last Name and First Name.

IF the user does not group by Department and Class rank, then I try to supress the department grouping by giving a formula under section expert for supress (x+2) of department. Hence the department names are not displayed.
Similar thing is done for Class rank.But the sorting of lname and fname are still based on departments, which is a problem
I hope I am making sense.

For eg.
If Department D1
Class Rank U01
James Kelly
Sam Manuels
Department D2
Class Rank U02
Adam Sinclair
Matthew Hayden

Now if i try to supress departments and Class rank
The report would generate

James Kelly
Sam Manuels
Adam Sinclair
Matthew Hayden
which I dont want.....


I want it as

Adam Sinclair
James Kelly
Matthew Hayden
Sam Manuels

I would basically want the grouping to happen based on what user selects. Any help would be greatly appreciated

--Vishal

 
The following solution would result in groupings based on the order of parameter selection, and so the user should be instructed in the parameter prompt that the order of entry is determining the order of groups.

First create a string parameter that allows multiple values, and use the following for parameter options:
"Department","Class Rank","Last Name","First Name". Then create four formulas and insert a group on each, in order:

//{@group1}:
if ubound({?Rows}) >= 1 then
if {?Rows}[1] = "Department" then {table.department} else
if {?Rows}[1] = "Class Rank" then {table.classrank} else
if {?Rows}[1] = "Last Name" then {table.lastname} else
if {?Rows}[1] = "First Name" then {table.firstname}

//{@group2}:
if ubound({?Rows}) >= 2 then
if {?Rows}[2] = "Department" then {table.department} else
if {?Rows}[2] = "Class Rank" then {table.classrank} else
if {?Rows}[2] = "Last Name" then {table.lastname} else
if {?Rows}[2] = "First Name" then {table.firstname}

Repeat for {@group3} and {@group4}, changing the 2's 3's or 4's.

After inserting groups on these, go to the section expert and select each group header/footer section and check "Suppress blank section".

-LB
 
lbass,
I am sorry I am still not able to figure out what I need to do.

Do I create 5 parameters, "Department","Class Rank","Last Name","First Name" and the last one being "ROW" ???


What values do I pass for these parameters ??

Thanks

--Vishal
 
Create one string parameter {?Rows} with the following options: "Department","Class Rank","Last Name","First Name". Then create 4 formulas like the examples above and insert a group on each.

-LB
 
lbass,
Thanks for the reply. I have created as you told me. But I am unable to figure out how do I pass the parameters to the report.

One mroe thing, whether the User groups it by Department/ClassRank or not, I have to group it by Last Name and First Name by default.

I have a check box, where the User selects if he needs to group it by department or not. Similarly its done for Class rank.

I check the condition

If Me.CheckBoxGroupbyDepartment.Checked = True Then
Val = New ParameterDiscreteValue
Val.Value = "Department"
paramRows.CurrentValues.Add(Val)
End If

And then
paramFields.Add(paramRows)
CRViewerEmailList.ParameterFieldInfo=paramFields

But the report still asks me for the parameter value

Any tips ???

Thanks

--Vishal
 
I can't help you if you are creating this inside another application. Within Crystal, you could simplify this by creating a string parameter {?Group} that allows multiple values and with two options: "Department" and "Rank".

Then you could create a formula {@group 1}:
if "Department" in {?Rows} then {table.department} else ""

{@Group2}:
if "Class Rank" in {?Rows} then {table.classrank} else ""

You would then insert a group #3 on {table.lastname} and a group #4 on {table.firstname} (or concatenate the two and insert the formula for Group #3.

Not sure how this would translate into your coding within your application.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top