'Openning Existing Crystal Reports With VB
Code By Kiran Reddy
'Openning Existing Crystal Reports With VB
'Reque:Crystal Reports Developer Edition Abouve ver 8.0, Visual Basic 6.0
'This code is for Oracle Databse and with one Sub report
'Please refer all related objects fron project --> references and one viewer
to viewer form or just Add Crystal Report from Project menu
'Crystal Object Declarations
Dim CRXReport As CRAXDDRT.Report 'CR
report
Dim CRXDb As CRAXDDRT.Database 'Cr DB
Dim CRXTbl As CRAXDRT.DatabaseTable 'CR tbl
Dim crxSubreport As CRAXDRT.Report 'Cr SubReports
Set CRXReport = Your_Report
Set CRXDb = CRXReport.Database
CRXReport.DiscardSavedData
inti = 1
Do Until inti = CRXReport.Database.Tables.Count + 1
CRXReport.Database.Tables.Item(inti).SetLogOnInfo strdblocation, "",
"", ""
inti = inti + 1
Loop
Set crxSubreport = CRXReport.OpenSubreport("YOUR_SUB_REPORT")
Set CRXDb = crxSubreport.Database
inti = 1
Do Until inti = crxSubreport.Database.Tables.Count + 1
crxSubreport.Database.Tables.Item(inti).SetLogOnInfo strdblocation, "",
"", "" 'set you database location
inti = inti + 1
Loop
With frmviewer 'this is your
form that contains viewrr
.Show ' show the viewer
.CRViewer1.ReportSource = CRXReport
.CRViewer1.ViewReport
'caption
End With
Set CRXReport = Nothing 'set nothing
Top