How do i preview a crystal report from within my vb program. I just want to preview it, not print it.
Printable View
How do i preview a crystal report from within my vb program. I just want to preview it, not print it.
add the crystal reports viewer control.. what version of crystal also?? I notice when people post crystal questions they never say what version they are using... I believe VB comes with 4.6 or something like that... but for instance I use version 8 that has different OCX controls that come with it.. so things are done differently
im using 8.5..i just added the viewer control.You know how to view the report? Thanks
well i use 8... i assume not much has changed... try adding this code
VB Code:
Public Sub RunReport() On Error GoTo EH: Dim CApp As New CRAXDRT.Application Dim CReport As CRAXDRT.Report Screen.MousePointer = vbHourglass ' Use the .OpenReport method of the Application object to set your Report object to a RPT file Set CReport = CApp.OpenReport("C:\MyReport.rpt") ' Use the DiscardSavedData method to ensure that your report hits the Database and refreshes the data CReport.DiscardSavedData crView.ReportSource = CReport CReport.Database.Tables(1).SetLogOnInfo "SERVER", "DBNAME", "LOGON", "PASSWORD" crView.ViewReport ' Zoom the preview window crView.Zoom 75 Screen.MousePointer = vbDefault Exit Sub EH: MsgBox Err.Description End Sub
make sure to add a reference to the crystal runtim library...
and crView is the name of the viewer control on a form...
Hi,
I tried doing this but it didn't seem to work. I added the crViewer control and also the Crystal report 7 ActiveX runtime library.
I get the error:
Object required. when I click okay it loads up as a blank form.
Any ideas.