Controlling printing

rob@trainease.com

New member
Local time
Today, 19:54
Joined
Jul 29, 2001
Messages
5
Does anyone out there have the code to select printer, tray and number of copies when opening a report? Is there an add-in for this?

The example in Help is no good at all.

Thanks
 
Check this link for the following:
http://www.microsoft.com/AccessDev/Articles/GetzCh10.HTM

Printer control from Access - Book Chapter -
Do you want to be able to control your printer directly from Access?

This sample chapter from the very popular Access Developer's Handbook [Getz et Al]provides a lot of valuable information Worth a bookmark
Chapter 10 from 'Access 95 Developer's Handbook' SYBEX
Online Chapter detailng how to control printers from within Access.

Don't be put off by the fact it is for Access 95 as a lot of the information also applies to later versions

Hope this helps
Regards
Trevor from http://www.sparkdb.co.uk
 
Hi

Before getting the accesswatch reply, I went off on a search and sort of found what I needed - which after a little work ended up as :-

First - a new Module "Printing"

Option Compare Database

Type zwtDevModeStr
RGB As String * 94
End Type

Type zwtDeviceMode
dmDeviceName As String * 16
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperlength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * 16
dmPad As Long
dmBits As Long
dmPW As Long
dmDFI As Long
dmDRr As Long
End Type


Then in the code behind your 'print' button :-

Dim Rpt As Report
Dim dm As zwtDeviceMode
Dim DevString As zwtDevModeStr
Dim DevModeExtra As String
Dim rptName As String
Dim tTray As Integer

' print the whites first

tTray = 2

rptName = "rpt_MtReportName"
'DoCmd.SetWarnings False
'Set Paper Tray for copy 1 white
DoCmd.OpenReport rptName, acDesign
Set Rpt = Reports(rptName)
DevModeExtra = Rpt.PrtDevMode
DevString.RGB = DevModeExtra
LSet dm = DevString
dm.dmDefaultSource = tTray
LSet DevString = dm
Mid$(DevModeExtra, 1, 68) = DevString.RGB
Rpt.PrtDevMode = DevModeExtra
DoCmd.Save acReport, Rpt.Name
DoCmd.SelectObject A_REPORT, Rpt.Name, True
DoCmd.PrintOut acPrintAll, , , acHigh, 2
' the last figure above = copies required
DoCmd.Close acReport, rptName, acSaveNo

'now print the yellow

tTray = 1

rptName = "rpt_MtReportName"
'DoCmd.SetWarnings False
'Set Paper Tray for copy 1 white
DoCmd.OpenReport rptName, acDesign
Set Rpt = Reports(rptName)
DevModeExtra = Rpt.PrtDevMode
DevString.RGB = DevModeExtra
LSet dm = DevString
dm.dmDefaultSource = tTray
LSet DevString = dm
Mid$(DevModeExtra, 1, 68) = DevString.RGB
Rpt.PrtDevMode = DevModeExtra
DoCmd.Save acReport, Rpt.Name
DoCmd.SelectObject A_REPORT, Rpt.Name, True
DoCmd.PrintOut acPrintAll, , , acHigh, 1
DoCmd.Close acReport, rptName, acSaveNo

Hope this effort helps someone else

Regards, rob@trainease.com
 

Users who are viewing this thread

Back
Top Bottom