NEED HELP on prtDevMode in setting the paper size
Hi guys....I had a problem with printing an invoice report on a continuous paper 4.75x5.5"....
Everytime users click button cmdPrintInvoice on frmOrderForm in order to print an invoice report rptInvoice based on OrderID popped up by input box(set within the query), it always prints on normal A3 paper 9.5"x11"...Even tough I have already set the paper size on the Page Setup at Report design view and Print Dialog box for printing an invoice report with the paper size 4.75"x5.5" (half A3 paper size), it's still not working...also there was no custom paper size function on the print dialog box
So, it is possible to force printing an invoice report with the paper size 4.75"x5.5" by using VBA code...I had looked on access help...and I think the problem is related with prtDevMode by setting the PaperLength and PaperWidth...but i am still learning about VBA and confuse in setting the papersize...I desperately need some help please...
Here is my original code for printing the invoice report:
Option Compare Database
Private Type str_DEVMODE
RGB As String * 94
End Type
Private Type type_DEVMODE
strDeviceName As String * 32
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 * 32
lngPad As Long
lngBits As Long
lngPW As Long
lngPH As Long
lngDFI As Long
lngDFr As Long
End Type
Public Sub CheckCustomPage(ByVal rptName As String)
Dim DevString As str_DEVMODE
Dim DM As type_DEVMODE
'Set constant page
'Const DM_intPaperSize = &H2
'Const DM_intPaperLength = &H4
'Const DM_intPaperLength = &H8
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
If DM.intPaperSize = 256 Then
' Display user-defined size.
intResponse = MsgBox("The current custom page size is " & _
DM.intPaperWidth / 254 & " inches wide by " & _
DM.intPaperLength / 254 & " inches long. Do you
want " & _
"to change the settings?", vbYesNo + vbQuestion)
Else
' Currently not user-defined.
intResponse = MsgBox("The report does not have a custom page
size. " & _
"Do you want to define one?", vbYesNo + vbQuestion)
End If
If intResponse = vbYes Then
' User wants to change settings. Initialize fields.
DM.lngFields = DM.lngFields Or DM.intPaperSize Or _
DM.intPaperLength Or DM.intPaperWidth
' Set custom page.
DM.intPaperSize = 256
' Prompt for length and width.
DM.intPaperLength = InputBox("Please enter page length in
inches.") * 254
DM.intPaperWidth = InputBox("Please enter page width in inches.")
* 254
' Update property.
LSet DevString = DM
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra
'print the report
DoCmd.OpenReport rptName, acNormal
End If
End If
Set rpt = Nothing
End Sub
when i type CheckCustomPage "rptInvoice" at the immediate window and type 4.75 " and 5.5" on the input box popped up, the rptInvoice still printed on 9.5"x11" paper size
Ohh, I'm using access xp on windows 2000 and Epson LQ1050+ printer (dot matrix)...sory for very long explanation...i tried to make it as clear as possible :D
Thanks a million in advance for any help and advice [:)
Cheers,
Fehrer
|