Skip to Content
0
Former Member
Sep 28, 2008 at 10:42 PM

Connecting sub reports from VB6

75 Views

I have built a report in Crystal XI that has two subReports. The report works fine when I run it from Crystal Designer, but when I integrate it into my App (VB6) I get the following error:

"This field name is not known"

If I remove the subReports from the report, the report runs, so I know the subReports are the problem, and strongly suspect that the subReport is not being opened properly.

This is the code I am using to open the subReports. Any help is greatly appreciated.

dim i as integer

i = 0

For Each CRXSection In CRXSections

Set CRXReportObjects = CRXSection.ReportObjects

For Each CRXReportObject In CRXReportObjects

If CRXReportObject.Kind = crSubreportObject Then

i = i + 1

Set CRXSubreportObj = CRXReportObject

Set CRXSubreport = CRXSubreportObj.OpenSubreport

Set rstSub(i) = RecordsetFactory

rstSub(i).open Sql(i), AppConnection, adOpenDynamic, adLockOptimistic

CRXSubreport.Database.SetDataSource rstSub(i), 3, 1

End If

Next CRXReportObject

Next CRXSection