Below is the code. I get an error message saying the object does not support this property or method where I have the code "Reports(stDocName).Printer = prt". I have used this code elsewhere (on other forms) and it works fine. I am using Access 2003. This code looks at a ComboBox and sets the printer according to what is in the ComboBox. I use it to allow for easier printing to Adobe PDF Writer.
Private Sub Command196_Click()
On Error GoTo Err_Command196_Click
Dim prt As Printer
Dim stDocName As String
stDocName = "repSeniority"
Set prt = Application.Printers(CLng(Me![Printers]))
prt.Orientation = acPRORPortrait
DoCmd.OpenReport stDocName, acPreview
Reports(stDocName).Printer = prt
DoCmd.PrintOut acPrintAll, , , acHigh
DoCmd.Close acReport, stDocName
Exit_Command196_Click:
Exit Sub
Err_Command196_Click:
msgbox Err.Description
Resume Exit_Command196_Click
End Sub
John Green
Private Sub Command196_Click()
On Error GoTo Err_Command196_Click
Dim prt As Printer
Dim stDocName As String
stDocName = "repSeniority"
Set prt = Application.Printers(CLng(Me![Printers]))
prt.Orientation = acPRORPortrait
DoCmd.OpenReport stDocName, acPreview
Reports(stDocName).Printer = prt
DoCmd.PrintOut acPrintAll, , , acHigh
DoCmd.Close acReport, stDocName
Exit_Command196_Click:
Exit Sub
Err_Command196_Click:
msgbox Err.Description
Resume Exit_Command196_Click
End Sub
John Green