Can someone please help ?
Inside Button click.... using Visual Studio 2005
I am trying to add sort fileds to my reports. I can't seem to get the code to WORK !!!!!!
I need to do it this way from VB.net 2005
Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim sDatabaseFile As String = "c:\data\mydata.mdb"
Dim sTableName As String = "tmpTable"
Dim crDatabaseFieldDefinition As CrystalDecisions.CrystalReports.Engine.DatabaseFieldDefinition
Dim crSortField As CrystalDecisions.CrystalReports.Engine.SortField
Dim crSortFields As CrystalDecisions.CrystalReports.Engine.SortFields
crReportDocument.Load(
"C:\reports\myReport.rpt")
crReportDocument.DataSourceConnections.Item(0).SetConnection(sDatabaseFile, sTableName,
False)
crDatabaseFieldDefinition = crReportDocument.Database.Tables(
"tmpTable").Fields("Last_Name")
' Note I have no sort fields in reports. Need to add sort fields !
crReportDocument.DataDefinition.SortFields.Item(0).Field = crDatabaseFieldDefinition
'Invalid index error ?
crSortFields = crReportDocument.DataDefinition.SortFields
crReportDocument.DataDefinition.SortFields(0).SortDirection = CrystalDecisions.Shared.SortDirection.AscendingOrder
CrystalReportViewer1.ReportSource = crReportDocument
P.S. anyone know of a good book that has this kind of sample code in it. That can help me manipulate reports at runtime.