Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Print 1 report to different printers

0 views
Skip to first unread message

rvdb

unread,
Sep 4, 1997, 3:00:00 AM9/4/97
to

I have a multi user application running in access '97 but can't work out
how to print the same report for one user (system)
to print to his local printer (lets say its called bob's printer) and for
the other user to his closest printer ( let's say john's printer)
Using printdev is not an option I think since I can't open the report in
design view and change it. (application is a runtime)
What I want is to define the closest printer for each user as wel as the
name of the fax and then print to that printer.

Annyone knows the answere

Please reply to

rv...@nem.hbg.nl

Gary Labowitz

unread,
Sep 5, 1997, 3:00:00 AM9/5/97
to

Access should use the default printer. Each user can set up a different
default printer.
That should do it.
Let us know.
--
Gary (MCT, MCPS, MCSD)
www.enter.net/~garyl/ for references to good books.
Contribute to ga...@enter.net


rvdb <rv...@dds.nl> wrote in article <01bcb97c$603b17e0$04e3b28f@bpi>...

(Pete Cresswell)

unread,
Sep 9, 1997, 3:00:00 AM9/9/97
to

>I have a multi user application running in access '97 but can't work out
>how to print the same report for one user (system)
>to print to his local printer (lets say its called bob's printer) and for
>the other user to his closest printer ( let's say john's printer)
>Using printdev is not an option I think since I can't open the report in
>design view and change it. (application is a runtime)
>What I want is to define the closest printer for each user as wel as the
>name of the fax and then print to that printer.

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

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

0 new messages