Using Crystal Report 9 in Visual Basic Reports
Author: Kevern V.
BuildDate: 02/03/2009
Version: v1.1.0
'Code to Command Button
Private Sub cmdPrint_Click()
Dim rsCollection As New ADODB.Recordset
Dim rptApps As New CRAXDRT.Application
Dim rptReport As New CRAXDRT.Report
With rsCollection
If .State = adStateClosed Then
.Open "Select * from YourTables", ConnModule.conn, adOpenDynamic, adLockOptimistic
On Error GoTo errHandler:
End If
Screen.MousePointer = vbHourglass
Set rptApps = CreateObject("CrystalRunTime.Application")
Set rptReport = rptApps.OpenReport(App.path & "\reports\Collection_Rep.rpt") 'Your Report Folder
frmReport.CRViewer91.ReportSource = rptReport
rptReport.Database.SetDataSource rsCollection
rptReport.PaperSize = crPaper10x14
On Err GoTo errHandler:
frmReport.CRViewer91.ViewReport
frmReport.CRViewer91.Refresh
frmReport.CRViewer91.Zoom 90
Screen.MousePointer = vbDefault
On Error GoTo errHandler:
End With
Exit Sub
errHandler:
MsgBox Err.Description, vbCritical, "Admin- System Error: Reports"
End Sub