windows desktop app

D

douglas

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
 
P

Pipo

Comments in line

douglas said:
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 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
=====> cryRpt = New ReportDocument
 

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