Printing reports using the bypass tray

I am trying to use the attached db (PrinterDemo.mdb) to print the "Catalog" report using the bypass tray on my Toshiba networked printer when the report opens in printpreview mode.  Not sure how to do this using the in-built modPrinters utility or what settings to change.  If this works, then I can customize my reports in my access db.  Need help please
PrinterDemo.mdb
sxxguptaAsked:
Who is Participating?
 
ee_autoConnect With a Mentor Commented:
Question PAQ'd and stored in the solution database.
0
 
Rey Obrero (Capricorn1)Commented:
see this link

How to Print a Report to Different Paper Trays
http://support.microsoft.com/?kbid=200546
0
 
Jeffrey CoachmanMIS LiasonCommented:
Your form basically simulates the Print Dialog box.

Why not just call this dialog box up directly and avoid re-inventing the wheel?

    DoCmd.RunCommand acCmdPrint
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Jeffrey CoachmanMIS LiasonCommented:
What version of Access please?

In Access 2007 and newer you can access the printer properties directly.

You can reference the PaperBin property to set this:

Application.Printer.PaperBin=


untitled.JPG
0
 
sxxguptaAuthor Commented:
I am using access 2002.  Most of my reports come out of the printer automatically, there are a few reports that if the user hits the print button embedded into the form, the report is sent to the bypass tray and the user feeds in paper manually (colored paper).  This is used to work well for me until we switched out the printers and now the manual coding does not work.  This is the coding snippet that used to work for me:

Private Sub Report_Open(Cancel As Integer)
Me.Printer.TopMargin = (1440 * 0.5)
Me.Printer.BottomMargin = (1440 * 0.166)
Me.Printer.LeftMargin = (1440 * 0.185)
Me.Printer.RightMargin = (1440 * 0.166)
Me.Printer.ColumnSpacing = (1440 * 0.1646)
Me.Printer.ItemSizeWidth = (1440 * 2.6)
Me.Printer.ItemSizeHeight = (1440 * 1)
Me.Printer.PaperBin = acPRBNManual
End Sub
0
 
Jeffrey CoachmanMIS LiasonCommented:
Then you may have to save these settings "In" the report.

Open the report in Design view and make a small change to the design of the report.
Now, open the Print Dialog box and change all the print settings you want.
Then save and close the report.
Compact and repair the DB and test the report.
0
 
sxxguptaAuthor Commented:
Hi:

Already tried that and it works....only for a limited number of users.  See, the problem is that I have the same db used by many users.  The problem is that these many users are connected to three totally different types of printers.  So I would need three different versions of the same db.....the management of that would not be feasible.....not to mention if our IT group decides to add more variety of printers.

I saw this article:

http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=101

But do not know how to apply it to Access since it applies to Word........
0
 
Jeffrey CoachmanMIS LiasonCommented:
Then (to me at least) this seems like an issue with the printer/Printer Driver...

So go to the Printer manufacturers web site and check for an updated driver.

And as always, make sure you have all your updates installed for Windows and Office
0
 
Helen FeddemaCommented:
Can you select the tray to use in the Printer applet?  If so, make a copy of the printer set for the Bypass tray, and then print to it.  I do this for duplexing.  Here is some sample code:
Public Sub EMailAllContacts()
'Created by Helen Feddema 31-Oct-2009
'Last modified by Helen Feddema 31-Oct-2009

On Error GoTo ErrorHandler

   Dim dbs As DAO.Database
   Dim rst As DAO.Recordset
   Dim appOutlook As Outlook.Application
   Dim msg As Outlook.MailItem
   Dim strEmail As String
   
   Set dbs = CurrentDb
   Set rst = dbs.OpenRecordset("qryContacts")
   Set appOutlook = GetObject(, "Outlook.Application")
   
   Do While Not rst.EOF
      strEmail = Nz(rst![EmailName])
      If strEmail <> "" Then
         'Create email
         Set msg = appOutlook.CreateItem(olMailItem)
         msg.To = strEmail
         msg.Subject = "Subject"
         msg.Body = "Message"
         
         'Comment out next line and uncomment Send line
         'to send automatically
         msg.Display
         'msg.Send
      End If
      rst.MoveNext
   Loop
   
ErrorHandlerExit:
   rst.Close
   Set rst = Nothing
   Set appOutlook = Nothing
   Exit Sub

ErrorHandler:
   'Outlook is not running; open Outlook with CreateObject
   If Err.Number = 429 Then
      Set appOutlook = CreateObject("Outlook.Application")
      Resume Next
   Else
      MsgBox "Error No: " & Err.Number _
         & " in EMailAllContacts procedure" _
         & "; Description: " & Err.Description
      Resume ErrorHandlerExit
   End If

End Sub

Open in new window

0
 
Helen FeddemaCommented:
This works fine in Access 2003 (and higher)
0
 
Helen FeddemaCommented:
Sorry, that was the wrong code.  Here is what I intended:
Public Sub PrintToSpecificPrinter(strPrinter As String, strReport As String)
'Created by Helen Feddema 12-Feb-2010
'Last modified by Helen Feddema 12-Feb-2010

On Error GoTo ErrorHandler

   Dim prtCurrent As Printer
   Dim prtDefault As Printer
   
   'Save current default printer
   Set prtDefault = Application.Printer
   Debug.Print "Current default printer: " & prtDefault.DeviceName
   
   'Select a specific printer as new default printer
   Application.Printer = Printers(strPrinter)
   
   'Print the report
   DoCmd.OpenReport strReport
   
   'Set printer back to former default printer
   Application.Printer = prtDefault
      
ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number & "; Description: " & _
      Err.Description
   Resume ErrorHandlerExit

End Sub

================================

Public Function ListPrinters()
'Lists Access printer names as used in VBA code
'to the Immediate window
  
   Dim prt As Access.Printer
   
   For Each prt In Application.Printers
      Debug.Print prt.DeviceName
   Next prt
   
End Function

Open in new window

0
 
Helen FeddemaCommented:
The ListPrinters procedure will give you the printer name to use in code
0
 
sxxguptaAuthor Commented:
Hi Helen:

Where to I call the Sub PrintToSpecificPrinter(strPrinter As String, strReport As String)?

My strPrinter name is "Adobe PDF" and what should strReport be set to.  Let's assume the name of the report is "zrpt"

Thanks.
0
 
sxxguptaAuthor Commented:
This works.  I have called a macro that uses the function setPaperSource("rptName") and call this macro on the click event of a button on my form.  Certain reports get certain printers and paperbins set automatically.
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

Function setPaperSource(rptName As String)

Dim Rpt As Report
Dim dm As zwtDeviceMode
Dim DevString As zwtDevModeStr
Dim DevModeExtra As String
Dim db As DAO.Database
Dim printerApp As Printer

Set db = CurrentDb


For j = 0 To db.Containers("Reports").Documents.Count - 1

    rptName = db.Containers("Reports").Documents(j).Name
   
    If rptName Like "Labels*" Then
   
        DoCmd.SetWarnings False
        'Set paper tray for bypass or manual depending on printer type
        DoCmd.OpenReport rptName, acDesign, , , acHidden
        Set Rpt = Reports(rptName)
        DevModeExtra = Rpt.PrtDevMode
        DevString.RGB = DevModeExtra
        LSet dm = DevString
        
        If Rpt.Printer.DriverName Like "*HP*" Then
            dm.dmDefaultSource = 272  'Integer to set paper bin
        ElseIf Rpt.Printer.DriverName Like ("*Toshiba*") Then
            dm.dmDefaultSource = 258  'Integer to set paper bin
        ElseIf Rpt.Printer.DriverName Like ("*Ricoh*") Then
            dm.dmDefaultSource = 4  'Integer to set paper bin
        End If
        
        LSet DevString = dm
        Mid$(DevModeExtra, 1, 68) = DevString.RGB
        Rpt.PrtDevMode = DevModeExtra
        DoCmd.Close acReport, rptName, acSaveYes
        DoCmd.SetWarnings True
        
    ElseIf rptName Like "z_*" Then
    
        DoCmd.SetWarnings False
        'Set paper tray for bypass or manual depending on printer type
        DoCmd.OpenReport rptName, acDesign, , , acHidden
        Set Rpt = Reports(rptName)
        DevModeExtra = Rpt.PrtDevMode
        DevString.RGB = DevModeExtra
        LSet dm = DevString
        Set printerApp = Application.Printers("Adobe PDF") 'Set default printer to Adobe
        Rpt.Printer = printerApp

        If Rpt.Printer.DriverName Like "*Adobe*" Then
            dm.dmDefaultSource = 15  'Integer to set paper bin
        End If
    
        LSet DevString = dm
        Mid$(DevModeExtra, 1, 68) = DevString.RGB
        Rpt.PrtDevMode = DevModeExtra
        DoCmd.Close acReport, rptName, acSaveYes
        DoCmd.SetWarnings True
    
    End If
Next

End Function

Open in new window

0
 
sxxguptaAuthor Commented:
Please close this question.  The above solution worked.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.