Symptom
- Missing sort control option in Crystal Reports.
- Unable to add control to sort a field on a report.
- It is possible to add Sort Control on the header of a database field on the main report, but the option is grayed out for database field in a subreport.
- Note: Images and data in this SAP Knowledge Base Article is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.
Environment
- SAP Crystal Reports 2011
- SAP Crystal Reports 2013
- SAP Crystal Reports 2016
- SAP Crystal Reports 2020
Reproducing the Issue
- In Crystal Reports, create a report off any data source.
- Add a subreport on the report off any data source.
- In the subreport, add at least one database field to the details section of the report.
- Sort the subreport by the database field added, by selecting "Record Sort Expert" under the menu "Report", and adding the field to the Sort Fields.
- Back to the subreport, to add a Sort Control, right click on the database field header, located in the Page Header section, but notice the option "Bind Sort Control..." is grayed out.
Cause
- The reason the option "Bind Sort Control" is grayed out, it is because by design this feature is not available in subreport.
- The Bind Sort Control feature, that add a control to sort a field in ascending, or descending order, is only available for the main report in Crystal Reports.
Resolution
- There is no option to add Sort Controls in a subreport, but a possible workaround is to create a parameter with an option for descending and ascending, and add a sort in the subreport to sort on a formula based on the value entered in the parameter.
- In the subreport, create a string parameter called like: Field Sort.
- Add 2 static values to the parameter, like: Ascending, and Descending.
- Create 2 formulas based on the value of the parameter, and add the database field to sort by, in the formula.
For example, if we want to sort by Country, in ascending, or descending order, then create a formula called: Ascending, like:
If {?Field Sort} = "Ascending" Then {Country} Else ""
Then create a second formula to sort in Descending order, like:
If {?Field Sort} = "Descending" Then {Country} Else ""
- Sort the records by both formula. To do so, select "Record Sort Expert" under the menu "Report"
- Add the formula "Ascending" to the "Sort Fields", and sort it in Ascending order.
- Add the formula "Descending" to the "Sort Fields", and sort it in Descending order.
Now, when viewing the report, it will be possible to change the parameter value from Ascending to Descending to control how the database field displays on the report.
Keywords
CR, Bind Sort, Sort Controls, missing , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , Problem
Product
SAP Crystal Reports 2011 ; SAP Crystal Reports 2013 ; SAP Crystal Reports 2016 ; SAP Crystal Reports 2020