We help IT Professionals succeed at work.

Visual Studio 2008 and Crystal Sort Option

jwebster77
jwebster77 asked
on
I have an application with a report in it, that when runs shows the report.   Similar to when you add parameters and a user is prompted when they run the report to enter the parameter is there any way to prompt the user when they run the report to allow them to select a sort option.  (I have two fields and I want them to be allowed to sort by either).  If not prompted, is there anyway for them to sort in the actual report when it is showing?
Comment
Watch Question

Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
I have that kind of reports with customizable sort options.

I ask the question before retrieving the values so it gives me time to alter my query to retrieve adding the proper "order by" clause to my query.

Check http://emoreau.com/Entries/Articles/2006/09/Feeding-Crystal-Reports-from-your-application.aspx to see how I am pushing my data to the report.
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
It can also be done with parameters as you suggest.

There are 2 ways to do it.

If the fields are the same type add a formula and change the sorting to use it.

If {?SortParam} = 'A' then
     {Field1}
Else
     {Field2}

If the fields are different types then use 2 sort fields and formulas
Assume Field1 is text and field2 is a number
Sort1
If {?SortParam} = 'A' then
     {Field1}
Else
     "A"

Sort2
If {?SortParam} = 'A' then
     0
Else
    {Field2}

mlmcc