'---------------------------------------------------------------------- 'Description 'This procedure prints or previews a report, and then closes the current 'instance of Microsoft Access (because objAccess is a procedure-level 'variable). 'Date 26/09/2001 AC 'Example PrintAccessReport(dbname:= _ ' "C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb", ' rptname:="Sales by Category", preview:=True) 'Called .... 'Master at www.ssw.com.au/ssw/kb/CodeBase '---------------------------------------------------------------------- Private Sub PrintAccessReport(ByVal dbname As String, ByVal rptname As String, ByVal preview As Boolean) Dim objAccess As Access.Application objAccess = New Access.Application() With objAccess .OpenCurrentDatabase(filepath:=dbname) If preview Then 'Preview report on screen. .Visible = True .DoCmd.OpenReport(reportname:=rptname, view:=Access.AcView.acViewPreview) Else 'Print report to printer. .DoCmd.OpenReport(reportname:=rptname, view:=Access.AcView.acViewNormal) End If End With objAccess = Nothing End Sub