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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upgrade from Crystal Reports 9 to XI in VB6

Status
Not open for further replies.

progenysend

Technical User
Feb 15, 2008
41
US
Hi,

Start this by saying I'm a Crystal Reports developer, not VB.

I've got an application that already uses Crystal 9. There's about 20 instances in the code where CRViewer91 is used. I need to upgrade this all to Crystal XI R2. So far, the problems I'm having...

I don't know what to update the CRViewer91 code to. CRViewer alone doesn't work.

CRViewer91.ReportSource = Report
CRViewer91.Refresh
CRViewer91.ViewReport


VB6 won't use the CrystalActiveXReportViewer unless I open it in administrator mode.

Thanks
 
Start a new project in order to see how it works.

Set a reference to (Project-References):

- Crystal Reports ActiveX Designer Run Time Library 11.5
(craxdrt.dll)

And A component reference to (Project-Components):
- Crystal ActiveX Report Viewer Library 11.5

Make sure you use the right components named exactly as I have.

Add a form called "Form1" with a command button called "Command1"
Add the following code to the code window of Form2
Code:
Option Explicit
Private Form2    As Form2
Private mstrFile As String
Private Sub Command1_Click()
    mstrFile = "c:\MyReports\SomeSavedReport.rpt"
    Set Form2 = New Form2
    Call Form2.Display(mstrFile)
End Sub
Add a second form called "Form2" and add the CR Viewer -named "CrystalActiveXReportViewer1" - to it by selecting the component from the ToolBox.

In Form2's code window:
Code:
Option Explicit
Private omCrystalApplication        As CRAXDRT.Application
Private WithEvents omCrystalReport  As CRAXDRT.Report

Public Sub Display(sFile As String)
    Call OpenReport(sFile)
    Me.Show
End Sub
Private Sub OpenReport(sFile As String)
    Set omCrystalApplication = New CRAXDRT.Application
    Set omCrystalReport = Nothing
    Set omCrystalReport = omCrystalApplication.OpenReport(sFile, crOpenReportByTempCopy)
    
    CrystalActiveXReportViewer1.ReportSource = omCrystalReport
    Call CrystalActiveXReportViewer1.ViewReport
End Sub

Set the project's startup object to Form1 (Project-Properties from Project1-Start object)

If you want the report window to show Modal, then change
Me.Show
to
Me.Show vbModal

The user will then need to close the report window prior to control returning to Form1

Add any other bells and whistles you want and be sure to add error handling

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top