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

Passing a Crystal Report into Report Viewer

Status
Not open for further replies.

SqueakinSweep

Programmer
Jun 20, 2002
945
GB
Im either missing the plot, or missing something obvious Im sure of it. I have a form named frmViewer, which is simply a form with a Crystal Viewer on it, and a few other controls. What I want to do is to pass the report to my viewer. This I can do as follows
Code:
Dim orep As New CrystalReport1
'Fill Report with data etc here...

Dim oViewer As New modReports.frmCrystal
'Here I pass in the Report to oViewer
oViewer.zRunReport(orep)

However in my viewers zRunReport Method, I have to specify the Crystal Report as an Object. This means I cant get at its methods without casting it as a Crystal Report??. So what Im after is either a way to cast this back as a base Crystal Report, or for the parameter in zRunReport to take a base Crystal Report

What does anyone else do as a workaround?




Sweep
...if it works dont mess with it
 
I knew I was missing something blindingly obvious.
For anyone else's reference...solution is posted

In my form frmCrystal, I have a Crystal Reports Viewer control named xCrystal

Code:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

'My Variables
Dim oReport As New ReportDocument
Dim oExp As ExportOptions
Dim oDir As New DiskFileDestinationOptions

Public Sub zRunReport(ByVal oRd As ReportDocument)

Me.oReport = oRd
Me.xviewer.ReportSource = Me.oReport
Me.Show()

End Sub

Public Sub zExporttoPDF(ByVal sFileName As String)

'Export File Format
oExp = Me.oReport.ExportOptions

oExp.ExportDestinationType =ExportDestinationType.DiskFile
oExp.ExportFormatType = ExportFormatType.PortableDocFormat
oDir.DiskFileName = sFileName
oExp.DestinationOptions = oDir

Me.oReport.Export()

End Sub




Sweep
...if it works dont mess with it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top