Got this from Crystal Decisions:
Here is sample code using the Add method with a Database field:
Syntax:
Sub Add(pFieldDefinition As IFieldDefinition, SortDirection As CRSortDirection)
- The first parameter only accepts a database field as specified by its index.
- The second specifies whether you want to sort in Ascending, Descending, Specified or Original order.
-Sample code
Dim Report As New CrystalReport1
Dim crxDatabaseFieldDefinitions As CRAXDRT.DatabaseFieldDefinitions
Dim crxDatabaseFieldDefinition As CRAXDRT.DatabaseFieldDefinition
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
'finds the first table in the report
Set crxDatabaseFieldDefinitions= Report.Database.Tables.Item(1).Fields
'sets the DatabaseFieldDefinition to the third field in the fields collection.
Set crxDatabaseFieldDefinition= crxDatabaseFieldDefinitions.Item(3)
Report.RecordSortFields.Add crxDatabaseFieldDefinition, crDescendingOrder
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub
Hope this helps!