SAP Knowledge Base Article - Public

2064840 - Unable to add a sort control to a field in a subreport in Crystal Reports

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. 

Environment

  • SAP Crystal Reports 2008
  • SAP Crystal Reports 2011
  • SAP Crystal Reports 2013
  • SAP Crystal Reports 2016

Reproducing the Issue

  1. In Crystal Reports, create a report off any data source.
  2. Add a subreport on the report off any data source.
  3. In the subreport, add at least one database field to the details section of the report.
  4. 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.
  5. 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.
     
    Bind Sort Control.png

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.
       
    1. In the subreport, create a string parameter called like: Field Sort.
        
    2. Add 2 static values to the parameter, like: Ascending, and Descending.
         
    3. 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 ""
          
       
    4. Sort the records by both formula. To do so, select "Record Sort Expert" under the menu "Report"
       
    5. Add the formula "Ascending" to the "Sort Fields", and sort it in Ascending order.
        
    6. 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 BusinessViews Manager , Problem

Product

Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports 2013 ; SAP Crystal Reports 2016