passing crystal report object

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
 
M

Mr. Arnold

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top