SortFields
SortFields specifies the field(s) that are to be used to sort your data when the report is printed.
Syntax
[form.]Report.SortFields(ArrayIndex)[= "{+|-} SortField"]
Enter the fields on which you want the data in your report to be sorted.
For example, to sort an order database alphabetically by customer, and then by order date, you can enter code similar to the following:
CrystalReport1.SortFields(0) = "+{orders.CUSTOMER}"
CrystalReport1.SortFields(1) = "+{orders.ORDERDATE}"
Remarks
- SortFields is an array property available only at runtime.
- Use a separate line of code to specify each sort field.
- Enter sort fields in the order that you want them to sort your report. For example, if you want your report to be sorted first on field A and then on field B, specify sort field A in your first line of code and sort field B in your second line of code.
- The sort field you specify must be assigned array index 0, the second sort field must be assigned array index 1, etc.
- The index values you assign must be continuous; no gaps are allowed (0, 1, 2 = OK, 0, 1, 3 = wrong).
- Array index values must be subscripted in the code immediately after the property name (i.e., CrystalReport1.SortFields(0) =).
- If you have specified sort fields for your report at Design Time, any sort fields you enter here will replace the sort fields in your report.
- If you do not use this property, the program will use the sorting instructions that you specified in the report.
- If you want to clear the sort fields in your report, use an empty string (i.e., CrystalReport1.SortFields(0) = "").
- Enclose field names in braces.
- Sort fields can be database fields or formula fields. If you sort on a formula field, use the @ sign before the formula name (i.e., {@FORMULANAME}).
Data Type
Array of strings
Availability
Runtime
Related Report Engine Functions
PESetNthSortField