Record Sorting in CR 11 on VB6
Okay. First off, let me say I am about to scream in frustration. I have a rather large business application developed in VB 6 that began life using Crystal Reports 8 and the Active X component. We have upgraded to CR 11 and I have begun replacing the CR 8's with CR 11's. One such report uses CR's sort. The old CR 8 code is listed below:
VB Code:
crWO.SelectionFormula = strSelect
crWO.SortFields(0) = "+{WOCompletions.Fail}"
crWO.Action = 1
This code took a variable, "strSelect", for it's runtime selection criteria and sorted the report off of the Table "WOCompletions" and Field "Fail" to create the report. According to numerous posts, the code listed below should accomplish the same goal:
VB Code:
Dim RPT as New crWOList
Dim crDBFDef as CRAXDRT.DatabaseFieldDefinition
Set crDBFDef = RPT.Database.Tables.Item(17).Fields.Item(6)
RPT.RecordSelectionFormula = strSelect
RPT.RecordSortFields.Add crDBFDef, crDescendingOrder
frmCRV.CRViewer1.ReportSource = RPT
frmCRV.Caption = "Work Orders By Failure Code"
frmCRV.Show
frmCRV.CRViewer1.ViewReport
However, this code generates an error 13, Type Mismatch at the Set statement. Any ideas? Please note, I have verified that the index numbers match the table and field I want by using the following statement:
VB Code:
Msgbox RPT.Database.Tables.Items(17).Fields.Items(6).Name
I cannot rule out the possibility that there is "cross-pollination" of CR 8 and CR 11 occurring since I am having to keep both sets of libraries loaded; not all of the reports have been, or can be, migrated over at this time. I haven't been able to locate the fully qualified type declarations for the DBFieldDef's and the RecordSortField.Add function, so I suppose it's possible one is CR 8 and the other is CR 11. Any help would be greatly appreciated!
Thanks in advance!