Determine if Report exists in current Database
Public Function IsReport(ReportName As String) As Boolean
Dim rpt As Access.AccessObject
For Each rpt In CurrentProject.AllReports
If rpt.Name = ReportName Then
IsReport = True
Exit For
End If
Next
End Function
|
Usage:
Debug.Print IsReport("MyReport")
| Home | Contents |
Print a Report to a chosen Printer
Public Function PrinterList() As String
Dim pr As Access.Printer
Dim r$
For Each pr In Application.Printers
r = r & ";" & pr.DeviceName
Next
If r <> "" Then
PrinterList = Mid$(r, 2)
End If
End Function
Public Sub SetDevice(ByVal pDevice As String)
Static SavedPrinter As String
With Application
If Len(pDevice) Then
SavedPrinter = .Printer.DeviceName
Set .Printer = .Printers(pDevice)
Else
Set .Printer = .Printers(SavedPrinter)
SavedPrinter = ""
End If
End With
End Sub
|
Preparation:
Usage:
The SetDevice procedure takes care of items 1, 2 and 4 as in the example below
SetDevice "The selected printer name" 'This saves the current Printer setting DoCmd.Printout ... SetDevice "" 'This sets the Default Printer to it's previous setting
| Home | Contents |