prettitoni
Programmer
I hope someone here can help me. I'm trying to call up a CR8.5 report with 2 subreports thru VB6 and can't get it to work. The primary report is filtering the correct records, but the subreports aren't. The queries are returning the correct records (I checked it in Access), but it's not reflecting on the report. This is what I have after I've set up my connections and queries....
For Each crxTable In crxReport.Database.Tables
crxTable.Location = App.Path & "\theDBname.mdb"
Next
crxReport.DiscardSavedData
crxReport.Database.SetDataSource rs1
Set crSections = crxReport.Sections
'Go through each section in the main report...
For Each crSection In crSections
Set crObjects = crSection.ReportObjects
For Each newObject In crObjects
If newObject.Kind = crSubreportObject Then
Set crxSubObj = newObject
Set crxSub = crxSubObj.OpenSubreport
crxSub.DiscardSavedData
If crxSubObj.SubreportName = "FReport.rpt" Then crxSub.Database.SetDataSource rs2
If crxSubObj.SubreportName = "F2Report.rpt" Then crxSub.Database.SetDataSource rs3
End If
Next newObject
Next crSection
CRViewer1.ReportSource = crxReport
CRViewer1.ViewReport
For Each crxTable In crxReport.Database.Tables
crxTable.Location = App.Path & "\theDBname.mdb"
Next
crxReport.DiscardSavedData
crxReport.Database.SetDataSource rs1
Set crSections = crxReport.Sections
'Go through each section in the main report...
For Each crSection In crSections
Set crObjects = crSection.ReportObjects
For Each newObject In crObjects
If newObject.Kind = crSubreportObject Then
Set crxSubObj = newObject
Set crxSub = crxSubObj.OpenSubreport
crxSub.DiscardSavedData
If crxSubObj.SubreportName = "FReport.rpt" Then crxSub.Database.SetDataSource rs2
If crxSubObj.SubreportName = "F2Report.rpt" Then crxSub.Database.SetDataSource rs3
End If
Next newObject
Next crSection
CRViewer1.ReportSource = crxReport
CRViewer1.ViewReport