passing crystal report object

  • Thread starter Thread starter douglas
  • Start date Start date
D

douglas

I am new to using Visual Basic.Net 2005. I want to pass a crystal report
object between two different click events. Below is my my code the way it
currently exists.
Can you tell me how to change the code so that the click events would be
aware of the crystal report object?

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class cryClass
Dim cryRpt As New ReportDocument
Dim excelFile As String = "c:\crystalExport.xls"

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cryRpt As New ReportDocument
cryRpt.Load("C:\crystalreport.rpt")
CrystalReportViewer1.ReportSource = cryalRpt
CrystalReportViewer1.Refresh()
Try
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New
CrystalDecisions.Shared.DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New
CrystalDecisions.Shared.ExcelFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = excelFile
CrExportOptions = cryalRpt.ExportOptions


With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.Excel
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
cryalRpt.Export()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
 
douglas said:
I am new to using Visual Basic.Net 2005. I want to pass a crystal report
object between two different click events. Below is my my code the way it
currently exists.
Can you tell me how to change the code so that the click events would be
aware of the crystal report object?

So why can't you make a Sub or a Function that deals with the object and you
can then call either one to create the object or do whatever to the object
from anywhere in the code, like two different events?
 
Back
Top