I want to sort my using options of comboboxes. The report displays perfectly, except the sort is not working and throws no errors. I'm using Crystal Reports version 10.0.0.533 and Visual Basic 6
Dim Report As New CRAXDRT.Report
Set Report = App1.OpenReport(g_ReportDirectory & "xxxx.rpt")
If cmbRefresh6.Text <> "" Then
Select Case cmbRefresh6.Text
Case "TestOne"
Report.RecordSortFields.Add Report.Database.Tables(2).Fields.Item(3), crDescendingOrder
Case "TestTwo"
Report.RecordSortFields.Add Report.Database.Tables(1).Fields.Item(23), crDescendingOrder
End Select
End If
If (cmbRefresh1.Text <> "") Then
Report.RecordSelectionFormula = "{WORK.ID}" = '1'
End If
The application opens the report, show the data is unordered.
I found my solution doing this. I created a group in my report and assigned to a formula field, the Report.Areas("GH3") refer to group header3 and Report.FormulaFields.Item(2) is my formula with the item to sort. I hope that helps you with similar problems having a second option to order.
If cmbRefresh6.Text <> "" Then
Select Case cmbRefresh6.Text
Case "TestOne"
Report.Areas("GH3").GroupConditionField = Report.FormulaFields.Item(3)
Report.Areas("GH3").SortDirection = crAscendingOrder
Case "TestTwo"
Report.Areas("GH3").GroupConditionField = Report.FormulaFields.Item(2)
Report.Areas("GH3").SortDirection = crAscendingOrder
End Select
End If