Annyone knows the answere
Please reply to
rvdb <rv...@dds.nl> wrote in article <01bcb97c$603b17e0$04e3b28f@bpi>...
There's a "gotcha" lurking in the default printer strategy.
Under NT server, at least, when the user changes printers paper size
is automagically reset to the default assigned by the network admin.
So, if your report is, say, legal landscape, and the user changes
printers... chances are that the new printer's default will be
letter...
To get around it, you've got to perform some machinations with a
structer called "PrtDevMode".
For better or worse, here's what I've been doing:
==============================
'------------------------------------------------------------------------
' These two types support our access to a report's prtDevMode
property.
' They were cloned from the "zwAllGlobals" module of allWZFRMRPT.MDA
and
' are used in reportPrintOne()
Type deviceModeString
dmStringValue As String * 512
End Type
Global Const gOrientationChanged = &H1
Global Const gPaperSizeChanged = &H2
Global Const gCopiesChanged = &H100
Global Const gYieldHistoryDataEntryWorkTableName =
"zstblYieldHistoryDataEntry"
Type deviceModeStructure
dmDeviceName As String * 32
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long 'Orientation = &H1, PaperSize =
&H2, Copies = &H100
dmOrientation As Integer 'Portrait = 1, Landscape = 2
dmPaperSize As Integer 'Letter = 1 Legal = 5
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
dmFiller As String * 444
End Type
Function reportPrintOne (theReportName As Variant, thePrintMode As
Integer, theCriteria As String, theNumberOfCopies As Integer,
thePaperSize, theOrientation) As Integer
15000 debugStackPush "basUtility: reportPrintOne"
15001 On Error GoTo reportPrintOne_err
' This function is necessitated by Access/NT's habit of changing
printer setup when the user's
' default printer matches assigned specific printer. Unfortunately
when this happens,
' the paper size and orientation get reset to the printer's default.
' Sounds harmless, but unfortunately the paper size also gets changed
to the default
' paper size for the printer - which is letter.
' What we're doing here is opening the report in design mode, forcing
it's paper size to
' legal, saving it (so the user doesn't get prompted "Save changes to
this report..."
' and then printing the report.
15005 Dim myDevString As deviceModeString
Dim myDevStruct As deviceModeStructure
Dim myReport As Report
Dim myTempString As String
Dim myReportName As String
Dim devName As String
Dim L As Integer
Dim x As Integer
Dim i As Integer
Dim skipLine As String
skipLine = Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10)
Const notFound = 3078
Const userCancelled = 2501
15107 myReportName = theReportName
15008 If gUserUpdatePermission = True Then
15009 DoCmd Echo False 'So user doesn't
see report in design mode
15010 DoCmd OpenReport theReportName, A_DESIGN
15165 myReportName = theReportName
15012 Set myReport = reports(myReportName)
15020 reports(theReportName).Painting = False
15030 If Not IsNull(myReport.prtDevMode) Then
15031 myTempString = myReport.prtDevMode
15035 myDevString.dmStringValue = myTempString
15040 LSet myDevStruct = myDevString
15045 myDevStruct.dmOrientation = theOrientation
15050 myDevStruct.dmPaperSize = thePaperSize
15059 myDevStruct.dmFields = myDevStruct.dmFields Or
gOrientationChanged Or gPaperSizeChanged
15060 LSet myDevString = myDevStruct
15065 Mid$(myTempString, 1, 68) = myDevString.dmStringValue
15070 myReport.prtDevMode = myTempString
15080 DoCmd SetWarnings False
15090 DoCmd DoMenuItem 7, A_File, 2 'Save the updated
report
15100 DoCmd SetWarnings True
15140 Else
15150 bugAlert True, "Null prtDevMode for: " & myReportName
15160 End If
15170 DoCmd Close A_REPORT, myReportName
15175 DoCmd Echo True
15176 End If
BypassPaperSetting:
15179 DoCmd SetWarnings False
15200 If thePrintMode = A_PREVIEW Then 'Do what we came
here to do: just print the report...
15210 DoCmd OpenReport myReportName, thePrintMode, , theCriteria
15220 Else
15230 For i = 1 To theNumberOfCopies
15240 DoCmd OpenReport myReportName, thePrintMode, ,
theCriteria
15298 Next i
15299 End If
15182 DoCmd SetWarnings True
15999 reportPrintOne = True
reportPrintOne_xit:
debugStackPop
Exit Function
reportPrintOne_err:
reportPrintOne = False
Select Case Err
Case notFound
If gUserUpdatePermission Then
MsgBox "One or more work tables are missing:" & skipLine &
Error, 48, "Please Refresh Work Tables"
Else
MsgBox "One or more work tables are missing." & skipLine &
"Your userID does not have permission to refresh work tables." &
skipLine & "Please ask someone with update permission to refresh the
work tables." & skipLine & Error, 48, "Cannot Run Report"
End If
Case userCancelled
MsgBox "Report Cancelled", 0, "Cancelled"
Case Else
bugAlert True, myReportName
End Select
Resume reportPrintOne_xit
End Function
==============================