Hi skg0509
I set up a form where the user can select their local printer and this is saved in a local (Front End) table (tblAdminInt).
Rather than use DoCmd.OpenReport the code calls this function to select the local printer.
CODE
Public Function PrintPrevReports(strDocName As String, Optional strCrit As String)
On Error GoTo err_proc
'Prints selected report
'Checks calibration dates etc entered
'sets Application.Printer to selected default printer, from stored printer in table tblAdminint
'Assumes all reports previewed
Dim rst As DAO.Recordset
Dim prt As Printer
Dim strPrinter As String
Set rst = db.OpenRecordset("tblAdminInt")
If rst.BOF = True Then GoTo exit_proc
rst.MoveFirst
strPrinter = Nz(rst!DefaultPrinter, "")
If strPrinter = "" Then
strMessage = "The default printer has not been set up." & Chr(13) & Chr(13) & _
"Please contact your system administrator."
MsgBox strMessage, vbExclamation, strTitle
GoTo exit_proc
End If
For Each prt In Application.Printers
If strPrinter = prt.DeviceName Then GoTo SetPrinter
Next
strMessage = "The assigned default printer is not available." & Chr(13) & Chr(13) & _
"Please contact your system administrator."
MsgBox strMessage, vbExclamation, strTitle
GoTo exit_proc
SetPrinter:
If StrComp(strPrinter, prt.DeviceName, vbBinaryCompare) <> 0 Then
rst.Edit 'Priner name is case sensitive -update tblAdminInt
rst!DefaultPrinter = prt.DeviceName
rst.Update
strPrinter = prt.DeviceName
End If
Application.Printer = Application.Printers(strPrinter)
Set prt = Application.Printers(strPrinter)
' Open and print the report using the new application-level printer settings.
DoCmd.OpenReport strDocName, acPreview, , strCrit
Reports(strDocName).Printer = prt
' Reset the application printer as the default.
Set Application.Printer = Application.Printers(0)
exit_proc:
On Error Resume Next
rst.Close
Exit Function
err_proc:
MsgBox err.Description, , strTitle
Resume exit_proc
End Function