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!

Help! I've upgraded to Crystal 9 using VB6 and I can't get (it) up!

Status
Not open for further replies.

modfather

MIS
Feb 15, 2000
75
US
I have a quick question for a newbie to Crystal Reports 9 (and I wasn't terribly good with older version either!) :)

I have a VB6 application that uses the "crystl32.ocx" in the following way:

With CRWreport
.WindowTitle = "My Title - March, 2003"
If chkPrint = False Then
.Destination = crptToWindow
Else
.Destination = crptToPrinter
.PrinterCopies = 1
End If
.ReportFileName = "e:\fullpath\myreport.rpt"
.DataFiles(0) = "e:\fullpath\mydatabase.mdb"
.SelectionFormula = "{table.fieldname} = " & "'" & txtfield & "'"
.Action = 1
End With

This was used to display and print a report. This code was originally done to work with Crystal Reports 5 or 6. Is there a new component that I use, that would be similar to this with Advanced Crystal 9?

Thanks very much for any help.
Steve
 
CR9 doesn't have an OCX. You will need to upgrade your app to the RDC (CRAXDRT.DLL)

We have been advised to migrate to the RDC since CR7. it is more complicated, but also far more powerful for VB integration. Editor and Publisher of Crystal Clear
 
Steve,

This is an example of how to preview a report using the new CRAXDRT.dll and the CRViewer9

'Delcare these variables

Private m_oApplication As CRAXDRT.Application
Private m_oDatabase As CRAXDRT.Database
Private m_oReport As CRAXDRT.Report
Private m_oParams As CRAXDRT.ParameterFieldDefinitions
Private m_oCRViewer As CRAXDRT.Report

'This sub is what gets call when the user wants to preview a report.

Public Sub PreviewReport(if you have parameters they would go into here)

Dim oParam As CRAXDRT.ParameterFieldDefinition

'Create Application object
Set m_oApplication = CreateObject ("CrystalRuntime.Application.9")
'Set report path
Set m_oReport = m_oApplication.OpenReport(put your report path location in here)

Set m_oCRViewer = m_oReport

Set m_oDatabase = m_oReport.Database

'Create the params objects if your report has params
Set m_oParams = m_oReport.ParameterFields

'Discard any old data
m_oReport.DiscardSavedData

'This is an example of how to set parameters if you have any
'otherwise just exclude this part and then preview.
'Set the first parameter
Set oParam = m_oParams(1) 'These are one based arrays
Call oParam.AddCurrentValue(parameter1)

'Set the second parameter
Set oParam = m_oParams(2) 'These are one based arrays
Call oParam.AddCurrentValue(parameter2)

'Tell the CRViewer where to get the report
'CRV is what I named the Crystal Report Viewer...you
'need to add this on your form in VB. If you have
'not loaded the component into your project then in VB you
'would go to Project/Components and then selecte the
'Crystal Report Viewer Control 9

CRV.ReportSource = m_oCRViewer
CRV.ViewReport

'This should bring up the form that you placed the CRViewer on. At this point you should be able to see the report.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top