Connecting sub reports from VB6
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
What database driver are you using ?
Try to update the database connection for the report.
You can do that by opening report in designer, then
Go To Database Menu -> Setdatasource Location
Connect to the datasource you want and update the datasource.
Save the report.Now run from application.
As you are having issue through code i would suggest
you to post this query to the NET Development - Crystal Reports forum:
That forum is monitored by qualified technicians and you will get a faster response there.
Thank you for your understanding,