ScottishFencer
Technical User
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
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.