Duplex printing only works on my local drive

R

Radhika

I have an access report that must print double- sided.
I have created a module with this code below:


Sub RestoreReportPrinter()
Dim rpt As Report
Dim prtOld As Printer
Dim prtNew As Printer

' Open the Invoice report in Print Preview.
DoCmd.OpenReport ReportName:="Single Pump Report",
View:=acViewPreview

' Initialize rpt variable.
Set rpt = Reports![Single Pump Report]

' Save the report's current printer settings
' in the prtOld variable.
Set prtOld = rpt.Printer

' Load the report's current printer settings
' into the prtNew variable.
Set prtNew = rpt.Printer

' Change the report's Orientation property.
prtNew.Duplex = acPRDPHorizontal

' Change other Printer properties, and then print
' or perform other operations here.

' If you comment out the following line of code,
' and a user interactively closes the report preview
' any changes made to properties of the report's Printer
' object are saved when the report is closed.
Set rpt.Printer = prtNew

' Close report without saving.
DoCmd.Close ObjectType:=acReport, ObjectName:="Single Pump
Report", Save:=acSaveNo

End Sub



Then, on my reports Activate Property, I call a macro, which runs this
module.
So, when I print, the report comes out in duplex.

The problem is this works out very well with my test database in my
local drive.
When I copy it over to the network,and print to my printer..it comes
out one-sided. Each and every person who is accessing this report will
need to print it to their individual printers.

Any idea on how to stop the double-sided option from becoming
unchecked when the file is on the network???

Thanks for any help in advance!
Radhika
 
S

SA

Rad:

The problem you are having is that you are trying to set report properties
such as layout from a print preview. You can NOT reliably adjust
report/printer properties once the report is open either in preview or in
print mode. To adjust this do the following:

1.) Open the report in design mode and while it is on your computer; select
the target printer that supports duplex mode using File -> Print Set Up ->
Page Tab -> Select Printer and then using the printers properties, set it to
print in duplex. Save the report. Then go to file ->Print Set up a
second time and on the page tab, set it to use the default printer and save
the report once again. This will store the duplex setting in the report.

The only time this won't work for all printers is if the user, from print
preview, changes the target printer by going to file -> Print and from the
print dialog selects a new printer rather than their default. This is
because when Access then switches to the new printer, it pulls in and adopts
that target printer default settings. If the default settings are NOT set
to duplex, then the report will not duplex when printed with the new
printer.

To manage that, what is normally done is that you eliminate the option to
print from the file menu and print preview toolbar by creating new custom
menus and toolbars for your report so the user doesn't have a chance to use
Access' Print dialog, which as noted above will load the printer's default
settings when you switch printers that way. Then on your form, create a
print button and a preview button, as well as a printers combobox.

You fill the combo by enumerating the Application objects printers
collection in the form's on Open event as in:
Sub Form_Open(Cancel as Integer)
Dim objPrinter As Printer
Dim boolSortTest As Boolean
Dim arrPrinters() As String, i As Byte, strTemp
ReDim arrPrinters(Application.Printers.Count - 1)
For Each objPrinter In Application.Printers
arrPrinters(i) = objPrinter.DeviceName
i = i + 1
Next
'Do an alpha sort, using a simple bubble sort; small list
boolSortTest = True
Do Until boolSortTest = False
boolSortTest = False
For intLoop = 0 To UBound(arrPrinters()) - 1
If (arrPrinters(intLoop) > arrPrinters(intLoop + 1)) And
Len(arrPrinters(intLoop + 1)) > 0 Then
strTemp = arrPrinters(intLoop)
arrPrinters(intLoop) = arrPrinters(intLoop + 1)
arrPrinters(intLoop + 1) = strTemp
boolSortTest = True
End If
Next intLoop
Loop
'Add them to the combo
For i = 0 To UBound(arrPrinters()) - 1
Me!cboPrinter.AddItem arrPrinters(i)
Next i
'Select the current application default
Me!cboPrinter = Application.Printer.DeviceName
End Sub
--------------
Then in after update event of the combo, where the user can pick the target
printer, you set the application's target printer as in:

Private Sub cboPrinter_AfterUpdate()
Dim objPrinter As Printer
For Each objPrinter In Application.Printers
If objPrinter.DeviceName = Me!cboPrinter Then
Application.Printer = objPrinter
End If
Next
End Sub

Then when your report is opened in either preview or is printed from the
buttons on the form, it a.) retains the duplex setting you saved in the
first instance and it output to the application's target printer set by the
user in the form.

2.) If you want to manage the Duplex setting for the report itself in code,
you have to open the report in design mode BEFORE you preview or print it as
in:

Docmd.Echo False
Docmd.OpenReport "Your Report", acviewDesign
Reports("YourReport").Painting = False

' Manage your printer properties here

Reports("yourReport").Painting = True
Docmd.Close acReport, "YourReport"
Docmd.Echo True

HTH
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg


Radhika said:
I have an access report that must print double- sided.
I have created a module with this code below:


Sub RestoreReportPrinter()
Dim rpt As Report
Dim prtOld As Printer
Dim prtNew As Printer

' Open the Invoice report in Print Preview.
DoCmd.OpenReport ReportName:="Single Pump Report",
View:=acViewPreview

' Initialize rpt variable.
Set rpt = Reports![Single Pump Report]

' Save the report's current printer settings
' in the prtOld variable.
Set prtOld = rpt.Printer

' Load the report's current printer settings
' into the prtNew variable.
Set prtNew = rpt.Printer

' Change the report's Orientation property.
prtNew.Duplex = acPRDPHorizontal

' Change other Printer properties, and then print
' or perform other operations here.

' If you comment out the following line of code,
' and a user interactively closes the report preview
' any changes made to properties of the report's Printer
' object are saved when the report is closed.
Set rpt.Printer = prtNew

' Close report without saving.
DoCmd.Close ObjectType:=acReport, ObjectName:="Single Pump
Report", Save:=acSaveNo

End Sub



Then, on my reports Activate Property, I call a macro, which runs this
module.
So, when I print, the report comes out in duplex.

The problem is this works out very well with my test database in my
local drive.
When I copy it over to the network,and print to my printer..it comes
out one-sided. Each and every person who is accessing this report will
need to print it to their individual printers.

Any idea on how to stop the double-sided option from becoming
unchecked when the file is on the network???

Thanks for any help in advance!
Radhika
 
R

Radhika

Thank You Steve. My report not only works now, but you have posted
some very valuable information that everyone will find useful to know
in access reports.
Thank you for sharing your time and expertise. God Bless!

Radhika




SA said:
Rad:

The problem you are having is that you are trying to set report properties
such as layout from a print preview. You can NOT reliably adjust
report/printer properties once the report is open either in preview or in
print mode. To adjust this do the following:

1.) Open the report in design mode and while it is on your computer; select
the target printer that supports duplex mode using File -> Print Set Up ->
Page Tab -> Select Printer and then using the printers properties, set it to
print in duplex. Save the report. Then go to file ->Print Set up a
second time and on the page tab, set it to use the default printer and save
the report once again. This will store the duplex setting in the report.

The only time this won't work for all printers is if the user, from print
preview, changes the target printer by going to file -> Print and from the
print dialog selects a new printer rather than their default. This is
because when Access then switches to the new printer, it pulls in and adopts
that target printer default settings. If the default settings are NOT set
to duplex, then the report will not duplex when printed with the new
printer.

To manage that, what is normally done is that you eliminate the option to
print from the file menu and print preview toolbar by creating new custom
menus and toolbars for your report so the user doesn't have a chance to use
Access' Print dialog, which as noted above will load the printer's default
settings when you switch printers that way. Then on your form, create a
print button and a preview button, as well as a printers combobox.

You fill the combo by enumerating the Application objects printers
collection in the form's on Open event as in:
Sub Form_Open(Cancel as Integer)
Dim objPrinter As Printer
Dim boolSortTest As Boolean
Dim arrPrinters() As String, i As Byte, strTemp
ReDim arrPrinters(Application.Printers.Count - 1)
For Each objPrinter In Application.Printers
arrPrinters(i) = objPrinter.DeviceName
i = i + 1
Next
'Do an alpha sort, using a simple bubble sort; small list
boolSortTest = True
Do Until boolSortTest = False
boolSortTest = False
For intLoop = 0 To UBound(arrPrinters()) - 1
If (arrPrinters(intLoop) > arrPrinters(intLoop + 1)) And
Len(arrPrinters(intLoop + 1)) > 0 Then
strTemp = arrPrinters(intLoop)
arrPrinters(intLoop) = arrPrinters(intLoop + 1)
arrPrinters(intLoop + 1) = strTemp
boolSortTest = True
End If
Next intLoop
Loop
'Add them to the combo
For i = 0 To UBound(arrPrinters()) - 1
Me!cboPrinter.AddItem arrPrinters(i)
Next i
'Select the current application default
Me!cboPrinter = Application.Printer.DeviceName
End Sub
--------------
Then in after update event of the combo, where the user can pick the target
printer, you set the application's target printer as in:

Private Sub cboPrinter_AfterUpdate()
Dim objPrinter As Printer
For Each objPrinter In Application.Printers
If objPrinter.DeviceName = Me!cboPrinter Then
Application.Printer = objPrinter
End If
Next
End Sub

Then when your report is opened in either preview or is printed from the
buttons on the form, it a.) retains the duplex setting you saved in the
first instance and it output to the application's target printer set by the
user in the form.

2.) If you want to manage the Duplex setting for the report itself in code,
you have to open the report in design mode BEFORE you preview or print it as
in:

Docmd.Echo False
Docmd.OpenReport "Your Report", acviewDesign
Reports("YourReport").Painting = False

' Manage your printer properties here

Reports("yourReport").Painting = True
Docmd.Close acReport, "YourReport"
Docmd.Echo True

HTH
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg


Radhika said:
I have an access report that must print double- sided.
I have created a module with this code below:


Sub RestoreReportPrinter()
Dim rpt As Report
Dim prtOld As Printer
Dim prtNew As Printer

' Open the Invoice report in Print Preview.
DoCmd.OpenReport ReportName:="Single Pump Report",
View:=acViewPreview

' Initialize rpt variable.
Set rpt = Reports![Single Pump Report]

' Save the report's current printer settings
' in the prtOld variable.
Set prtOld = rpt.Printer

' Load the report's current printer settings
' into the prtNew variable.
Set prtNew = rpt.Printer

' Change the report's Orientation property.
prtNew.Duplex = acPRDPHorizontal

' Change other Printer properties, and then print
' or perform other operations here.

' If you comment out the following line of code,
' and a user interactively closes the report preview
' any changes made to properties of the report's Printer
' object are saved when the report is closed.
Set rpt.Printer = prtNew

' Close report without saving.
DoCmd.Close ObjectType:=acReport, ObjectName:="Single Pump
Report", Save:=acSaveNo

End Sub



Then, on my reports Activate Property, I call a macro, which runs this
module.
So, when I print, the report comes out in duplex.

The problem is this works out very well with my test database in my
local drive.
When I copy it over to the network,and print to my printer..it comes
out one-sided. Each and every person who is accessing this report will
need to print it to their individual printers.

Any idea on how to stop the double-sided option from becoming
unchecked when the file is on the network???

Thanks for any help in advance!
Radhika
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top