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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report printing to default printer?

Status
Not open for further replies.

ScottishFencer

Technical User
Sep 27, 2005
74
GB
Hello,

I have a problem with a report. It is launched from a command button. When the report launches it gathers together the information and then prints to a specified machine. The problem is that this printer is broken and I cannot locate where in the code it is defined.

here is the code

Code:
Option Compare Database
Option Explicit

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

Sub setPaperSource(rptName As String)
         Dim Rpt As Report
         Dim dm As zwtDeviceMode
         Dim DevString As zwtDevModeStr
         Dim DevModeExtra As String
            Dim x As Integer
If vPage = 1 Then
         DoCmd.SetWarnings False 'DoCmd SetWarnings in Microsoft Access 2.0
         ' Set Paper Tray for page 1
         DoCmd.OpenReport rptName, acDesign
         ' Docmd OpenReport in Microsoft Access 2.0
         Set Rpt = Reports(rptName)
         DevModeExtra = Rpt.PrtDevMode
         DevString.RGB = DevModeExtra
         LSet dm = DevString
         dm.dmDefaultSource = 3  '1 = Upper Tray, 2 = Lower Tray, 5 = _
                                 'Envelope Feeder
         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 A_PAGES, 1, 1
         DoCmd.Close     ' Closes the report
         DoCmd.SetWarnings True
End If

If vPage > 1 Then
   
         DoCmd.SetWarnings False 'DoCmd SetWarnings in Microsoft Access 2.0
         ' Set Paper Tray for page 1
         DoCmd.OpenReport rptName, acDesign
         ' Docmd OpenReport in Microsoft Access 2.0
         Set Rpt = Reports(rptName)
         DevModeExtra = Rpt.PrtDevMode
         DevString.RGB = DevModeExtra
         LSet dm = DevString
         dm.dmDefaultSource = 1  '1 = Upper Tray, 2 = Lower Tray, 5 = _
                                 'Envelope Feeder
         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 A_PAGES, 1, 1
         
        For x = 2 To vPage

            ' Set Paper Tray for page 2
            DoCmd.OpenReport rptName, acDesign
            Set Rpt = Reports(rptName)
            DevModeExtra = Rpt.PrtDevMode
            DevString.RGB = DevModeExtra
            LSet dm = DevString
            dm.dmDefaultSource = 2  '1 = Upper Tray, 2 = Lower Tray, 5 = _
                                 'Envelope Feeder
            LSet DevString = dm
            Mid$(DevModeExtra, 1, 68) = DevString.RGB
            Rpt.PrtDevMode = DevModeExtra
            DoCmd.Save A_REPORT, Rpt.Name
            DoCmd.SelectObject A_REPORT, Rpt.Name, True
            DoCmd.PrintOut acPages, x, x
            DoCmd.Close     ' Closes the report
            DoCmd.SetWarnings True
        
        Next x
 End If
      End Sub


[/close]

This was written by the previous techie and I note that it seems to be cobbled together from MS examples.  The obvious variable is 'DeviceName' however I cannot locate where in the code it is defined.

Has anyone had any experience of this code before?  Can you point me in the right direction? 

The printer must be specified somewhere as the same printer is specified when I open the report - however I cannot see anywhere in the report design or properties where the printer is specified.
 
hi
check your report and see what printer is set there
and maybe you can change the printer in the report



Durango122
 
With your report in design mode, go to File>Page Setup>Page. There is a place at the bottom that says "Printer for" reportname. Then it has options for "Default Printer" and "Use Specific Printer". That's where I usually set mine anyway.
 
I admit that I didn't think to look at "default printer" setup. I'm feeling a bit sheepish. Yes indeed that is where it was all setup - unfortunately this is a bulk run which uses about 20 different reports... Each individually set up and each set up to use that one broken printer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top