Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code for printer settings? 1

Status
Not open for further replies.

TheEnigma

Technical User
May 26, 2002
69
US
Hi there,

I currently have a button set up in a form in access to automatically print out a report. The only problem is that I need to have the report print to tray 2, where as the default on the printer is tray 1. The reason for this is that it needs to be printed on coloured paper rather than the normal white paper.

When printing manually this can be done.

Does anyone know if there is a macro or some code that will automate this?

Thanks in advance...
 
You should be able to set up the printer for tray 2 while in design view, then save the report. Printer settings are saved with the report definition.

It can be done in code using the DefaultSource setting of the PrtDevMode property of the Report, but I warn you, it's not fun. PrtDevMode is a Windows API data structure, and you have to jump through some hoops to manipulate it. The help file covers it. Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
You can try this... I haven't used it for a long time, but it used to work...

'needs to be in a module

Type str_DEVMODE
RGB As String * 94
End Type

Type type_DEVMODE
strDeviceName As String * 16
intSpecVersion As Integer
intDriverVersion As Integer
intSize As Integer
intDriverExtra As Integer
lngFields As Long
intOrientation As Integer
intPaperSize As Integer
intPaperLength As Integer
intPaperWidth As Integer
intScale As Integer
intCopies As Integer
intDefaultSource As Integer
intPrintQuality As Integer
intColor As Integer

intDuplex As Integer
intResolution As Integer
intTTOption As Integer
intCollate As Integer
strFormName As String * 16
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type

Sub PrintTop(rptName As String, Reference As Long) 'Force printer to print from top tray
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE
Dim strDevModeExtra As String
Dim rpt As Report
Dim intResponse As Integer
' Opens report in Design view.
DoCmd.OpenReport rptName, acDesign

Set rpt = Reports(rptName)
If Not IsNull(rpt.PrtDevMode) Then
strDevModeExtra = rpt.PrtDevMode ' Gets current DEVMODE structure.
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.intDefaultSource = 3

LSet DevString = DM ' Update property.
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra

End If

End Sub

Sub PrintBottom(rptName As String, Reference As Long) 'Force printer to print from bottom tray
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE
Dim strDevModeExtra As String
Dim rpt As Report
Dim intResponse As Integer
' Opens report in Design view.
DoCmd.OpenReport rptName, acDesign

Set rpt = Reports(rptName)
If Not IsNull(rpt.PrtDevMode) Then
strDevModeExtra = rpt.PrtDevMode ' Gets current DEVMODE structure.
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.intDefaultSource = 2

LSet DevString = DM ' Update property.
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra

End If

End Sub There are two ways to write error-free programs; only the third one works.
 
Try the printer object.

(type printer.)

You should see an option for paperbin...
 
The printer object? Where do I find that? :eek:)
 
GHolden ..... this code you posted. Would this work for Access 97 or is it specific to an earlier vrsion?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top