Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem populatnig Crystal 9 from VB6

Status
Not open for further replies.

MaxSterling

Programmer
Feb 18, 2003
1
US
Hello,

First post here, hope somebody has some ideas...

I'm trying to populate a Crystal 9 report (with a single subreport) using VB6 and an ado recordset returned from a SQL Server 2000 database via a stored procedure. This worked perfectly with a V7 report but when I converted to 9, I found that the method had changed.

I found an article on crystaldecisions for version 8. (scr8_ttxado.pdf) It recommended the code below (I've been playing with it to try to get it to work). I had to use "Passing an ADO recordset to a subreport via the RDC" rather than "Passing an ADO recordset to a subreport via the Crystal
Automation Server" because I couldn't find the appropriate references it mentioned for the latter.

The recordsets populate, but nothing happens when it gets to:

CrViewer1.ViewReport

No error or anything, just nothing happens. I did add CrViewer1 (CRViewer 9 object)


My general from declarations:

'declarations for crystal 9
Dim CrAppl As New CRAXDRT.Application
Dim CrRep As CRAXDRT.Report
Dim CrDatabase As CRAXDRT.Database
Dim CrDatabaseTables As CRAXDRT.DatabaseTables
Dim CrDatabaseTable As CRAXDRT.DatabaseTable
Dim CrSections As CRAXDRT.Sections
Dim CrSection As CRAXDRT.Section
Dim CrReportObjs As CRAXDRT.ReportObjects
Dim CrSubreportObj As CRAXDRT.SubreportObject
Dim CrSubreport As CRAXDRT.Report

'ADO Recordset object for main report
Dim AdoRs As New ADODB.Recordset

'ADO Recordset object for subreport
Dim AdoRs1 As New ADODB.Recordset


---------------------------------

My code to fire the report:

Private Sub OpenJacketNewCrystal()
'Reference "Passing an ADO recordset to the report via the RDC"
'scr8_ttxado.pdf from crystaldecision

Dim x As Integer
Dim y As Integer

Dim lngContractID As Long, strReportName As String, strReportPathName As String

lngContractID = fnGetDropIDValue("ContractID")
strReportName = "Jacket Report.rpt"
strReportPathName = gstrReportsPath & "\" & strReportName

'open the ADO recordset for the main report
' AdoRs.Open "Select * from Customer", "Xtreme Sample"
' Database ", adOpenDynamic, adLockBatchOptimistic"

Set AdoRs = modMisc.fnGetJobJacketData(lngContractID)
If AdoRs.RecordCount = 0 Then GoTo RoutineExit

'open the ADO recordset for the subreport
' AdoRs1.Open "Select * from Customer", "Xtreme Sample"
' Database ", adOpenDynamic, adLockBatchOptimistic"

Set AdoRs1 = modMisc.fnGetJobJacketSupportSubData(lngContractID)

'Open the report.
'Set CrRep = CrAppl.OpenReport("C:\Files\Development\Ectobox\Red Square\ContractsBilling\reports\Jacket Report-9.rpt")
Set CrRep = CrAppl.OpenReport(strReportPathName)



'Set the database, database tables and database table for
'the main report by using the SetDataSource method.
Set CrDatabase = CrRep.Database
Set CrDatabaseTables = CrDatabase.Tables
Set CrDatabaseTable = CrDatabaseTables.Item(1)
CrDatabaseTable.SetDataSource AdoRs, 3

'Loop through each section and report object. When a
'subreport object is found, set the subreport object to a
'report object.
Set CrSections = CrRep.Sections

For x = 1 To CrSections.Count
Set CrSection = CrSections.Item(x)
Set CrReportObjs = CrSection.ReportObjects
For y = 1 To CrReportObjs.Count
If CrReportObjs.Item(y).Kind = crSubreportObject Then
Set CrSubreportObj = CrReportObjs.Item(y)
Set CrSubreport = CrSubreportObj.OpenSubreport

'Set the database, database tables and database table for
'the subreport by using the SetDataSource method
Set CrDatabase = CrSubreport.Database
Set CrDatabaseTables = CrDatabase.Tables
Set CrDatabaseTable = CrDatabaseTables.Item(1)

CrDatabaseTable.SetDataSource AdoRs1, 3
End If
Next
Next
CrViewer1.ReportSource = CrRep

CrViewer1.ViewReport

RoutineExit:

End Sub



-----------------

References that I added for this:

1) Crystal Reports 9 ActiveX designer run time library
2) Crystal Report Viewer Control 9

thanks very much for any help that anyone can offer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top