on 06-17-2008 5:38 PM
I am using Visual Studio 2005, Visual Basic syntax, SqlServer 2000 and CrystalReports XI to build a Windows Forms application. I have a form that allows the user to define criteria for a report which I pass as a parameter to a ReportDocument object. I now want to allow the users to define the sort fields also. But it appears that the sort fields of the object are readonly. Can I define the sort fields of the ReportDocument class in my code?
Hi Connie,
There should be a sort field sample in the following samples package:
[http://support.businessobjects.com/communityCS/FilesAndUpdates/vbnet_web_samples.exe.asp]
Also, make sure you are using Crystal Reports XI Release 2 (11.5.xxx) with VS.NET 2005 and not Crystal Reports XI (11.0.xx) since XI is not supported with .NET 2005.
Good luck,
Jason
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, I thought my question was answered. It was a very good example. But.... I want to allow the users to select more than 1 field to sort by. I have created the following function and it works if I only have 1 item, but it fails on the 2nd item if I have more than 1. Can you sort by more than 1 item? And also, it is breaking to a new page for every new last name (my sort), is there a property I need to set so it does not do that? Thanks for your help.
Private Function lfSort(Byval pSortList As List(Of Miscellaneous3))
'pSortList contains a list of fields that the user wants this report to be sorted by
'the list contains 3 items: 1)Code=the field name as defined in the table 2)Display1=the field name in English, not geek talk 3)Display2=the sort order
Dim lSortFld As String
Dim lSortDir As String
Dim crDatabaseFieldDefinition As DatabaseFieldDefinition
Dim crSortField As SortField
If pSortList.Count > 0 Then
For i As Integer = 0 To pSortList.Count - 1
lSortFld = pSortList(i).Code
If pSortList(i).Display2 = "Desc" Then
lSortDir = SortDirection.DescendingOrder
Else
lSortDir = SortDirection.AscendingOrder
End If
'set the crystal parameters
crDatabaseFieldDefinition = crReportDocument.Database.Tables(0).Fields(lSortFld.ToString)
crSortField = crReportDocument.DataDefinition.SortFields(i)
crSortField.Field = crDatabaseFieldDefinition
crSortField.SortDirection = lSortDir
Next
End If
End Function
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.