DNA7433
Aug 13th, 2007, 01:13 PM
I was printing reports using this code a couple weeks ago and since then I've been developing the program but I haven't been testing the print function. Now printing won't work. The code runs, seemingly without error, but nothing ever prints.
Private Sub PrintReport(ReportFilename As String, SelectionFormula As String, Copies As Byte)
Dim crApp As New CRAXDDRT.Application, rpt As CRAXDDRT.Report
Set rpt = crApp.OpenReport(ReportFilename, crOpenReportByTempCopy)
rpt.RecordSelectionFormula = SelectionFormula
Dim Database As String, Security As String, conStr As String
Database = App.Path & "\[database name removed]"
Security = App.Path & "\[security db name removed]"
conStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Database & ";" & _
"Jet OLEDB:System database=" & Security & ";Persist Security Info=False"
crApp.LogOnServerEx "p2soledb.dll", Database, "", [user name removed], [password removed], "OLE DB", conStr
Dim i As Long
For i = 1 To rpt.Database.Tables.Count
rpt.Database.Tables(i).ConnectionProperties("Password") = [password removed]
Next
rpt.PrintOutEx True, CInt(Copies)
Set rpt = Nothing
Set crApp = Nothing
It used to pop up a dialog asking me which printer to use and it no longer does that either. Is there some method similar to the Win32 API GetLastError that I could use to determine what the hell is going on?
Thanks!
Private Sub PrintReport(ReportFilename As String, SelectionFormula As String, Copies As Byte)
Dim crApp As New CRAXDDRT.Application, rpt As CRAXDDRT.Report
Set rpt = crApp.OpenReport(ReportFilename, crOpenReportByTempCopy)
rpt.RecordSelectionFormula = SelectionFormula
Dim Database As String, Security As String, conStr As String
Database = App.Path & "\[database name removed]"
Security = App.Path & "\[security db name removed]"
conStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Database & ";" & _
"Jet OLEDB:System database=" & Security & ";Persist Security Info=False"
crApp.LogOnServerEx "p2soledb.dll", Database, "", [user name removed], [password removed], "OLE DB", conStr
Dim i As Long
For i = 1 To rpt.Database.Tables.Count
rpt.Database.Tables(i).ConnectionProperties("Password") = [password removed]
Next
rpt.PrintOutEx True, CInt(Copies)
Set rpt = Nothing
Set crApp = Nothing
It used to pop up a dialog asking me which printer to use and it no longer does that either. Is there some method similar to the Win32 API GetLastError that I could use to determine what the hell is going on?
Thanks!