Tuesday, March 20, 2012

Crystal reports [vb6]

I need some help with Crystal - I am new to the package and I'm battling with the VB integration

My current .vbp project has a form with the following code

General Declaration

Public CrxApplication As New CRAXDRT.Application
Public CrxReport As New CRAXDRT.Report

Then in my code (I'm showing a menu - depending what the user chooses...)

Select Case Index
Case 0
openfile.Filter = "Reports (*.rpt)|*.rpt"
openfile.ShowOpen
If openfile.FileName <> "" Then
Set CrxReport = CrxApplication.OpenReport(openfile.FileName, 0)
CrxReport.Database.LogOnServer "p2sodbc.dll", dsn, dbName, UserName, UserPassword
'? "p2ssql.dll" vir sql?
CRViewer1.ReportSource = CrxReport
CRViewer1.ViewReport
End If
Case 2
----------
CrxReport.PrinterSetup Me.hWnd (HERE the error occurs)
----------
Case 3
CRViewer1.PrintReport

Case 5
End

End Select


when CASE = 2 my program errors - 'Method 'printersetup' of object 'Ireport' failed

what does this mean? I am not using an "Ireport' somewhere

Pse help

Thanks!Not sure about the IReport.

But, you havent SET CrxReport under "2"...

shouldnt that have been done ?|||IReport is the interface|||Dim crystal As New CRAXDRT.Application
Dim report As New CRAXDRT.report
Dim ms As String
Private Sub Command1_Click()
ms = "1"
Set report = crystal.OpenReport("C:\test\Report\test.rpt")
report.Database.LogOnServer "p2sodbc.dll", "test", "test", "test", "test"

CRViewer91.ReportSource = report
CRViewer91.ViewReport
Do While CRViewer91.IsBusy
DoEvents
Loop
CRViewer91.Zoom 77

End Sub
Private Sub CmdPrinterSetting_Click()
If ms = "" Then
MsgBox "ReportSource is Nothing"
Exit Sub
Else

report.PrinterSetup Me.hWnd
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
ms = ""
Set crystal = Nothing
Set report = Nothing
End Sub

pls check

if CRViewer91.ReportSource is nothing
this error will be found

No comments:

Post a Comment