Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005-2015 : Writing Code
Message Icon Topic: Add Sort Fields Post Reply Post New Topic
Author Message

Joined: 01 Feb 2008
Location: Canada
Online Status: Offline
Posts: 2
Quote Joe_G Replybullet Topic: Add Sort Fields
    Posted: 01 Feb 2008 at 10:04pm
Can someone please help ?Cry
 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.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 ?Ouch

 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.

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

This page was generated in 0.016 seconds.