I have inherited a process that is meant to produce reports through Crystal and then send them out. I am trying to add a report to be automatically sent out through this process but it seems to be getting stuck on the Export() call. There is a lot of set up that takes in an ini file to determine how the report is delivered and stuff like the rpt file name and the name of the file to be produced, so I'm leaving that all out.
FRM.reportDocument1.Load(ReportFile)
'Setup Crystal Report Database Connection
Dim myDBConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo
'Set Selection Formula
If ReportFile.IndexOf("TotalAdmissions_V3.rpt") > 0 Then
FRM.reportDocument1.RecordSelectionFormula = ""
ElseIf ReportFile.IndexOf("AccountsThatFailProration.rpt") > 0 Then
FRM.reportDocument1.RecordSelectionFormula = ""
ElseIf ReportFile.IndexOf("statoe.rpt") > 0 Then
FRM.reportDocument1.RecordSelectionFormula = ""
Else
FRM.reportDocument1.RecordSelectionFormula = SelectCriteria
End If
With myDBConnectionInfo
.ServerName = DataBaseServer
.DatabaseName = DataBaseName
.UserID = UserID
.Password = Password
End With
'Apply Crystal Reports Database Information to all Tables.
Dim myTableLogonInfo As New CrystalDecisions.Shared.TableLogOnInfo
Dim myDatabase As Object = FRM.reportDocument1.Database
Dim myTables As Object = myDatabase.Tables
Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
For Each myTable In myTables
myTableLogonInfo = myTable.LogOnInfo
myTableLogonInfo.ConnectionInfo = myDBConnectionInfo
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
FRM.reportDocument1.Refresh()
'Print to a printer
'frm.reportDocument1.PrintOptions.PrinterName = PrinterName
'frm.reportDocument1.PrintToPrinter(1, True, 0, 0)
'Print to PDF
Dim myExportOptions As New CrystalDecisions.Shared.ExportOptions
Dim myDiskFileDestinationOptions As New CrystalDecisions.Shared.DiskFileDestinationOptions
Dim myFormatTypeOptions As New CrystalDecisions.Shared.PdfRtfWordFormatOptions
myDiskFileDestinationOptions.DiskFileName = (FileName)
myExportOptions = FRM.reportDocument1.ExportOptions
If FileFormat = "PDF" Then
With myExportOptions
.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
.DestinationOptions = myDiskFileDestinationOptions
.FormatOptions = myFormatTypeOptions
End With
'Skipping rest of If Else as it is not necessary
FRM.reportDocument1.Export()
It is getting stuck on the last line, the Export call. It is not erroring. The Form just kind of freezes and I have to kill the process in the task manager or end the debugging session if I'm debugging in Visual Studio.
This process is used for dozens of other crystal reports that get run every single day. Looking and comparing, I tried to find something that was different about the set up but the only thing I could find was that this new report has direct connections to 5 views on the database it is getting data from and uses the Select Expert to narrows down results while the others all have a Command in the Crystal report that they call. They also call a different database, this new report is for a database that has no reports that use this VB process. I am able to get a report to generate within the SAP Crystal Reports application, so I know the username, password, server, database, etc are all correct.
I've tried going through the debugger and getting the values for the reports that work vs the new report. I've searched and searched for previous questions with no luck finding anything close enough to what I'm doing. I am using SAP Crystal Reports 2013. The file is a copy of another and I do not know where it originated, but I have saved it and made slight edits to it within CR 2013. I am looking at the code and debugging in Microsoft Visual Studio 2015. I am also very not experienced in using Visual Studio or VB a whole lot as I've only used it a few times to troubleshoot some other processes.