Report printing in different orientations (1 Viewer)

sphere_monk

Registered User.
Local time
Today, 03:05
Joined
Nov 18, 2002
Messages
62
Hi all,

I'm running a pop-up form that allows the user to select a printer when a report has to be run.

There is a specific report that is designed to be printed in landscape mode in the report itself.

When the user prints the report using the "Print to Current Printer" button, the code behind the button prints the report in landscape, like it is designed:
Code:
Private Sub cmdPrintToCurrent_Click()
On Error Resume Next

DoCmd.OpenReport Me!txtReportName, acNormal

DoCmd.Close acForm, "frmSystemSelectPrinter"

End Sub

When the user prints the report using the "Print to Different Printer" button (after selecting the same printer) the code behind the button prints the same report in portrait, essentially ignoring the fact that the report is designed to print in landscape orientation:

Code:
Private Sub cmdPrintToDifferent_Click()
On Error Resume Next

Dim varReportName As String

varReportName = txtReportName.Value

DoCmd.OpenReport varReportName, View:=acPreview, WindowMode:=acHidden
Set Reports(varReportName).Printer = Application.Printers(cboSelectPrinter.ListIndex)
DoCmd.OpenReport varReportName, View:=acViewNormal

Forms!frm_Menu!cboSelectPrinter = Me!cboSelectPrinter

DoCmd.Close acReport, varReportName

DoCmd.Close acForm, "frmSystemSelectPrinter"

End Sub

Just to be clear: the report is actually saved as landscape orientation in design mode. When I open the report in design mode, landscape is selected and saved.

Many different reports are printed using this form and the code associated with it, so I'd like to avoid any statements within the code that force landscape, if possible.

I don't have a lot of experience with this kind of code. Is there something in the code for the "Print to Different Printer" that could be ignoring the orientation saved within the report itself?

Any help you could provide would be greatly appreciated!

Dan
 

informer

Registered User.
Local time
Today, 09:05
Joined
May 25, 2016
Messages
75
Hi sphere_monk

Try this :eek:
Code:
Me.Printer.Orientation = acPRORLandscape

here for more information
 
Last edited:

sphere_monk

Registered User.
Local time
Today, 03:05
Joined
Nov 18, 2002
Messages
62
Awesome. Thanks Informer. I was able to get a workaround going with the printer statement you gave me. Here's the new code:

Code:
Private Sub cmdPrintToDifferent_Click()
On Error Resume Next

Dim varReportName As String

varReportName = txtReportName.Value

DoCmd.OpenReport varReportName, View:=acPreview, WindowMode:=acHidden
Set Reports(varReportName).Printer = Application.Printers(cboSelectPrinter.ListIndex)
If varReportName = "rptAccountsAMIDoorTags" Then Reports(varReportName).Printer.Orientation = acPRORLandscape
DoCmd.OpenReport varReportName, View:=acViewNormal

Forms!frm_Menu!cboSelectPrinter = Me!cboSelectPrinter

DoCmd.Close acReport, varReportName

DoCmd.Close acForm, "frmSystemSelectPrinter"

End Sub

Essentially I'm just forcing the orientation for that report.

THANK YOU! This gets me going.

I'm still curious why the original code would cause the printer to ignore the orientation saved with the report, if anyone knows. As it stands, I'll have to add any more reports this happens to to the "IF" statement that forces the orientation programmatically.

Dan
 

Users who are viewing this thread

Top Bottom