rlevasseur
Programmer
I have created a small VB application for running a selected crystal 8.5 report in background. I open a SQL server query and loop through values to run report multiple times, creating a PDF exported report. The form is invisible. I used example on page 124 of Crystal 8.5 delelopers guide. When I create an install package and install on another machine I get a run time error 2147190548, Missing or out of date export dll. Error points to crxdrt.dll. The application runs fine on my workstation
Attached is code I am using. I need help getting this running on another machine.
I was using the old ocx control in prior versions, but users want reports in pdf format, without having to run reports. References to old ocx control have been removed
Any help anyone can give greatly appreciated
Thanks, Ray
-----------------------------------------------------
VB Code
Private Sub Form_Load()
On Error GoTo MISRptError
StartTime = Now()
sServer = "myserver"
sDatabaseName = "mydatabase"
sUserName = "mylogin"
sPassword = "mypassword"
cn.ConnectionTimeout = 2000
cn.Provider = "sqloledb"
cn.Properties("Data Source".Value = sServer
cn.Properties("Initial Catalog".Value = sDatabaseName
cn.Properties("User ID".Value = sUserName
cn.Properties("Password".Value = sPassword
cn.Open
Dim rs1 As ADODB.Recordset
Set rs = New ADODB.Recordset
Set rs1 = New ADODB.Recordset
LogPath = "\\myserver\My path\MIS Extracts Out\ReportMailLog.txt"
Open LogPath For Output As #1
Print #1, "----------------------------------------------------"
Print #1, "Program : RptScheduler.exe "
Print #1, "Author : Ray Levasseur March 2002 MIS Department "
Print #1, "Purpose : Creates and e-mails selected reports in "
Print #1, " batch mode. "
Print #1, "----------------------------------------------------"
Print #1, "Started : " & Format(StartTime, "mm/dd/yyyy hh:mm:ss"
SqlStr = "Select AcctMgr, MgrEMail from AcctMgrInfo " & _
"where MgrEmail is not null " & _
"order by MgrSequence"
rs.Open SqlStr, cn
rs.MoveFirst
While Not rs.EOF
ParamStr = Trim(rs!AcctMgr)
RptFileName = "AcctMgrTest.rpt"
RptPath = "\\myserver\Mypath\Crystal Reports\"
RptOutPath = "\\myserver\My path\MIS Extracts Out\"
RptNamePath = Trim(RptPath & RptFileName)
Set Report = crxApplication.OpenReport(RptNamePath, 1)
For Each crxDatabaseTable In Report.Database.Tables
crxDatabaseTable.SetLogOnInfo CStr(sDatabaseName), CStr(sDatabaseName), CStr(sUserName), CStr(sPassword)
Next crxDatabaseTable
Set crxParameterField = Report.ParameterFields.Item(1)
crxParameterField.AddCurrentValue CStr(ParamStr)
Set crxExportOptions = Report.ExportOptions
crxExportOptions.DestinationType = crEDTDiskFile
crxExportOptions.FormatType = crEFTPortableDocFormat
crxExportOptions.DiskFileName = Trim(RptOutPath & "AcctMgrTest_" & ParamStr & ".pdf"
Report.DisplayProgressDialog = False
Report.Export False
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
CRViewer1.Visible = False
Print #1, "Report generated for : " & ParamStr & " Mailto: " & Trim(rs!mgremail)
'If chkSendMail.Value = 1 Then
' SqlStr = "exec stp_rRptSendMail " & "'" & Trim(rs!mgremail) & "','" & Trim("AcctMgrTest_" & ParamStr & ".pdf" & "'"
' rs1.Open SqlStr, cn
'End If
rs.MoveNext
Wend
rs.Close
StopTime = Now()
Print #1, "Program Completed : " & Format(StopTime, "mm/dd/yyyy hh:mm:ss"
Close #1
cn.Close
MISRptError:
If Err.Number = 0 Then Exit Sub
Beep
MsgBox CStr(Err.Number) & " - " & Err.Description & vbCrLf & " Error during batch report creation " & vbCrLf & "." & vbCrLf & "Error cause: " & Err.Source
End
Exit Sub
End Sub
-----------------------------------------------------
module code
Option Explicit
Public cn As New ADODB.Connection
Public rs As ADODB.Recordset
Public SqlStr As String
Public RptPath As String
Public LogPath As String
Public RptFileName As String
Public RptNamePath As String
Public RptOutName As String
Public RptOutPath As String
Public sServer As String
Public sDatabaseName As String
Public sUserName As String
Public sPassword As String
Public bCancel As Boolean
Public cntr As Long
Public ParamStr As String
Public StartTime As Date
Public StopTime As Date
Public showdate As String
Public showcurr As String
Public crxApplication As New CRAXDRT.Application
Public Report As CRAXDRT.Report
Public crxDatabaseTable As CRAXDRT.DatabaseTable
Public crxParameterField As CRAXDRT.ParameterFieldDefinition
Public crxExportOptions As CRAXDRT.ExportOptions
Private Sub Main()
Load frmRptSched
End
End Sub
Attached is code I am using. I need help getting this running on another machine.
I was using the old ocx control in prior versions, but users want reports in pdf format, without having to run reports. References to old ocx control have been removed
Any help anyone can give greatly appreciated
Thanks, Ray
-----------------------------------------------------
VB Code
Private Sub Form_Load()
On Error GoTo MISRptError
StartTime = Now()
sServer = "myserver"
sDatabaseName = "mydatabase"
sUserName = "mylogin"
sPassword = "mypassword"
cn.ConnectionTimeout = 2000
cn.Provider = "sqloledb"
cn.Properties("Data Source".Value = sServer
cn.Properties("Initial Catalog".Value = sDatabaseName
cn.Properties("User ID".Value = sUserName
cn.Properties("Password".Value = sPassword
cn.Open
Dim rs1 As ADODB.Recordset
Set rs = New ADODB.Recordset
Set rs1 = New ADODB.Recordset
LogPath = "\\myserver\My path\MIS Extracts Out\ReportMailLog.txt"
Open LogPath For Output As #1
Print #1, "----------------------------------------------------"
Print #1, "Program : RptScheduler.exe "
Print #1, "Author : Ray Levasseur March 2002 MIS Department "
Print #1, "Purpose : Creates and e-mails selected reports in "
Print #1, " batch mode. "
Print #1, "----------------------------------------------------"
Print #1, "Started : " & Format(StartTime, "mm/dd/yyyy hh:mm:ss"
SqlStr = "Select AcctMgr, MgrEMail from AcctMgrInfo " & _
"where MgrEmail is not null " & _
"order by MgrSequence"
rs.Open SqlStr, cn
rs.MoveFirst
While Not rs.EOF
ParamStr = Trim(rs!AcctMgr)
RptFileName = "AcctMgrTest.rpt"
RptPath = "\\myserver\Mypath\Crystal Reports\"
RptOutPath = "\\myserver\My path\MIS Extracts Out\"
RptNamePath = Trim(RptPath & RptFileName)
Set Report = crxApplication.OpenReport(RptNamePath, 1)
For Each crxDatabaseTable In Report.Database.Tables
crxDatabaseTable.SetLogOnInfo CStr(sDatabaseName), CStr(sDatabaseName), CStr(sUserName), CStr(sPassword)
Next crxDatabaseTable
Set crxParameterField = Report.ParameterFields.Item(1)
crxParameterField.AddCurrentValue CStr(ParamStr)
Set crxExportOptions = Report.ExportOptions
crxExportOptions.DestinationType = crEDTDiskFile
crxExportOptions.FormatType = crEFTPortableDocFormat
crxExportOptions.DiskFileName = Trim(RptOutPath & "AcctMgrTest_" & ParamStr & ".pdf"
Report.DisplayProgressDialog = False
Report.Export False
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
CRViewer1.Visible = False
Print #1, "Report generated for : " & ParamStr & " Mailto: " & Trim(rs!mgremail)
'If chkSendMail.Value = 1 Then
' SqlStr = "exec stp_rRptSendMail " & "'" & Trim(rs!mgremail) & "','" & Trim("AcctMgrTest_" & ParamStr & ".pdf" & "'"
' rs1.Open SqlStr, cn
'End If
rs.MoveNext
Wend
rs.Close
StopTime = Now()
Print #1, "Program Completed : " & Format(StopTime, "mm/dd/yyyy hh:mm:ss"
Close #1
cn.Close
MISRptError:
If Err.Number = 0 Then Exit Sub
Beep
MsgBox CStr(Err.Number) & " - " & Err.Description & vbCrLf & " Error during batch report creation " & vbCrLf & "." & vbCrLf & "Error cause: " & Err.Source
End
Exit Sub
End Sub
-----------------------------------------------------
module code
Option Explicit
Public cn As New ADODB.Connection
Public rs As ADODB.Recordset
Public SqlStr As String
Public RptPath As String
Public LogPath As String
Public RptFileName As String
Public RptNamePath As String
Public RptOutName As String
Public RptOutPath As String
Public sServer As String
Public sDatabaseName As String
Public sUserName As String
Public sPassword As String
Public bCancel As Boolean
Public cntr As Long
Public ParamStr As String
Public StartTime As Date
Public StopTime As Date
Public showdate As String
Public showcurr As String
Public crxApplication As New CRAXDRT.Application
Public Report As CRAXDRT.Report
Public crxDatabaseTable As CRAXDRT.DatabaseTable
Public crxParameterField As CRAXDRT.ParameterFieldDefinition
Public crxExportOptions As CRAXDRT.ExportOptions
Private Sub Main()
Load frmRptSched
End
End Sub