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

Viewing and refreshing Crystal Reports with VB 6.0

Status
Not open for further replies.

stigejg

Technical User
Mar 28, 2001
55
NO
Hi,

I have just started to learn about visual basic and woundering if it is possible to view av ready made crystal report with VB a easey way?

The report is made with crystal report 8.0 and it would be real elegant if it is possible to view and refresh it with VB.

Anyone with a hint?

Kind regard Stig
 
There are so many ways you could go about this, from simple to complex. If you have the developer editions, you will find quite a few good examples that got me started, even go to seagatesoftware.com and check out there tutorials. I have included some code from one of my projects to give you a idea..hope you can follow..its weak in documentation :)

================code=================
Public crxRpt As CRAXDRT.Report
Public crxApp As New CRAXDRT.Application

Dim flagRS As Integer
Dim strDB As String



Private Sub cmdClose_Click()
Unload Me
End Sub

Private Sub CRViewer1_OnReportSourceError(ByVal errorMsg As String, ByVal errorCode As Long, UseDefault As Boolean)
MsgBox errorMsg
End Sub

Private Sub Form_Load()

Call reload
flagRS = 0
CRViewer1.EnableExportButton = True
CRViewer1.EnableRefreshButton = True
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = crxRpt
CRViewer1.ViewReport
CRViewer1.Zoom 1
Screen.MousePointer = vbDefault
Exit Sub

rpt_err:
MsgBox "Error in processing report...", _
vbCritical + vbOKOnly, _
"Report error"

Exit Sub
End Sub

Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0

cmdClose.Top = ScaleHeight - 15 - cmdClose.Height
cmdClose.Left = ScaleHeight - 15 - cmdClose.Width

CRViewer1.Height = ScaleHeight - cmdClose.Height - 30
CRViewer1.Width = ScaleWidth - 15
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set crxRpt = Nothing
Set crxApp = Nothing



Set frmReportViewer = Nothing

End Sub
'Reloads data source ..rptLocName = path and name of report eg. c:\temp\report.rpt
Private Sub reload()

Set crxRpt = crxApp.OpenReport(rptLocName, 1)

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top