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)
Of course there are 4 different ways depending on your integration method. If you don't know your method, see the FAQ in the general forum on "Questions should include.." Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
Dim Report As New CRAXDRT.Report
Dim crxDatabaseFieldDefinitions As CRAXDRT.DatabaseFieldDefinitions
Dim crxDatabaseFieldDefinition As CRAXDRT.DatabaseFieldDefinition
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
' Fails on the below line
Set crxDatabaseFieldDefinitions = Report.Database.Tables.Item(1).Fields
Set crxDatabaseFieldDefinition = crxDatabaseFieldDefinitions.Item(3)
Report.RecordSortFields.Add crxDatabaseFieldDefinition, crDescendingOrder
frmViewer.CRViewer.ReportSource = Report
frmViewer.CRViewer.ViewReport
Screen.MousePointer = vbDefault
End Sub
I am using Crystal Reports 8.5 Professional and SQL Server Database. I am not sure what do you mean by "how is the report connected to database"?
I am afraid that 8.5 professional doesn't integrate with VB. You need 8.5 developer. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.