Dynamically change group by in crystal report

Hi,

I am working on a winforms application using Vb.Net.

On the form(Front End), i have a combobox.
I have to group my report based on the value selected in the combobox.
This has a sub group within it.Sub group also has to change.
How can i do this?


For ex. if the combobox has 3 values: date, state
By default, i am grouping by date.
Within each date i group by state.
and then i subgroup the vendors.

Date
   
   State
       Vendors


Now, if i select state in the combobox on the main form,
my report should look like

State
   
   Date
      Vendors


Thanks
shahjagatAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mlmccConnect With a Mentor Commented:
You indicated the combo box has 3 values.  What is the third value?
I assume the user could group based on Date, State, or Vendor.

If they can only choose from Date and State then you would have 2 formulas
Group1
If {?UserGroup}) =  "Date" then
    CStr({DateField},"yyyy/mm/dd")
Else
    {StateField}

Group2
If {?UserGroup}) =  "State" then
    CStr({DateField},"yyyy/mm/dd")
Else
    {StateField}

mlmcc
0
 
mlmccCommented:
Will you only be changing/selecting the outer grouping?
Will the order of the other 2 change?

You could base the groups on formulas
Group1

If {?UserGroup}) =  "Date" then
    CStr({DateField},"yyyy/mm/dd")
Else If {?UserGroup}) =  "State" then
    {StateField}
Else
    {VendorField}

Assuming only the outer changes
Group2
If {?UserGroup}) =  "State" then
    CStr({DateField},"yyyy/mm/dd")
Else
    {StateField}


Group3
If {?UserGroup}) =  "Vendor" then
    CStr({DateField},"yyyy/mm/dd")
Else
    {VendorField}

A formula can only return 1 datatype so you have to convert the date fields to strings.  The format I chose will allow the dates to sort naturally

mlmcc
mlmcc
0
 
shahjagatAuthor Commented:
hi mlmcc,

We need to change 2 groupings.
Outermost and the next one.
Innermost will remain same. It will not change.


For the time being we decided to go ahead with a fixed way(not allowing the user to change anything).
But at some point in future we will have to include that feature.


Thanks
0
 
shahjagatAuthor Commented:
Thanks
0
All Courses

From novice to tech pro — start learning today.