R
Ross
I am trying to print reports from multiple closed databases from the current
databases.
I have a Sub that Opens the external database and prints the report. How do
I close the report and close the external database when done?
Here is what I have so far:
Sub PrintAccessReport()
Dim dbName As String
Dim rptName As String
Dim Preview As Boolean
Dim objAccess As Object
On Error GoTo PrintAccessReport_ErrHandler
Set objAccess = CreateObject("Access.Application")
With objAccess
dbName = "C:\A_FinSOL_Reports\Master_Source_Db\02-NDS_CSV Loan Setup
Data Acquisition.mdb"
rptName = "rpt_dropped_records"
Preview = True
.OpenCurrentDatabase filepath:=dbName
If Preview Then 'Preview report on screen.
.Visible = True
.DoCmd.OpenReport reportname:=rptName, _
view:=Access.acPreview
Else 'Print report to printer.
.DoCmd.OpenReport reportname:=rptName, _
view:=Access.acNormal
DoEvents 'Allow report to be sent to printer.
End If
End With
Set objAccess = Nothing
Exit Sub
PrintAccessReport_ErrHandler:
MsgBox Error$(), , "Print Access Report"
End Sub
databases.
I have a Sub that Opens the external database and prints the report. How do
I close the report and close the external database when done?
Here is what I have so far:
Sub PrintAccessReport()
Dim dbName As String
Dim rptName As String
Dim Preview As Boolean
Dim objAccess As Object
On Error GoTo PrintAccessReport_ErrHandler
Set objAccess = CreateObject("Access.Application")
With objAccess
dbName = "C:\A_FinSOL_Reports\Master_Source_Db\02-NDS_CSV Loan Setup
Data Acquisition.mdb"
rptName = "rpt_dropped_records"
Preview = True
.OpenCurrentDatabase filepath:=dbName
If Preview Then 'Preview report on screen.
.Visible = True
.DoCmd.OpenReport reportname:=rptName, _
view:=Access.acPreview
Else 'Print report to printer.
.DoCmd.OpenReport reportname:=rptName, _
view:=Access.acNormal
DoEvents 'Allow report to be sent to printer.
End If
End With
Set objAccess = Nothing
Exit Sub
PrintAccessReport_ErrHandler:
MsgBox Error$(), , "Print Access Report"
End Sub