Printer tray setup at remote location (1 Viewer)

ellenr

Registered User.
Local time
Today, 10:42
Joined
Apr 15, 2011
Messages
397
My client prints invoices on letterhead from tray 1 and office copy from tray 2. I connect remotely. I can't set up print properties on remote system.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:42
Joined
May 7, 2009
Messages
19,175
can you use:

docmd.RunCommand acCmdPrint

so you can set which tray to use during printing.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 14:42
Joined
Sep 12, 2006
Messages
15,614
My client prints invoices on letterhead from tray 1 and office copy from tray 2. I connect remotely. I can't set up print properties on remote system.

Surely you would test this on your own system to get the code right, and then apply the same code to the client system.

one way to try is to set the access printer to a specific printer (even if it's the default)

set application.printer = printers("printer_name") *** see note
then see if you can change the tray by using the application.printer object
application.printer.usetray = 2 'whatever the command is
when you're finished
set application.printer = nothing
to restore the default printer.

I don't think this will change the active tray for the default printer, but you should check

*** now the printer name is actually case sensitive when you do this. You are better iterating all the printers until you find the one your want.

Code:
'this sort of thing

for each ptr in application.printers
  if application.printer.devicename = requiredprinter then etc ' this test is not case sensitive
  'OR EVEN
  if instr(application.printer.devicename,requiredprinter)>1 then etc  'in case it's called something like "printer1 on server4".
next
 

Cliff67

Registered User.
Local time
Today, 07:42
Joined
Oct 16, 2018
Messages
175
Hi everyone

So I'm trying to do the same here, my report needs to be printed on blue paper in tray 4 (don't ask I don't know why).

So far I Have
Code:
Private Sub CmdPrint_Click()
Dim TempRpt As TempVars
Dim TempNo As TempVars
TempVars!TempRpt = Me.ID.Value
TempVars!TempNo = Me.RMANo.Value

On Error GoTo ErrHand
    Set Application.Printer = Printers("Samsung X4300 Series")
    Application.Printer.PaperBin = acPRBNLower
    DoCmd.OpenReport "Rpt_RMA", acViewNormal
    Set Application.Printer = Nothing
On Error GoTo 0
Exit Sub

ErrHand:
strSEM = dfSEM(Err.Number, Err.Description, "Frm_Repair_Main", "CmdPrint_Click")
MsgBox strSEM, vbInformation, "Technical Support and Repairs Database"
Err.Clear
Exit Sub
End Sub

but it doesn't print from tray 4 or the lowest tray. if I specify "Tray 4" I get a type mismatch

Any help would be appreciated
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:42
Joined
May 7, 2009
Messages
19,175
can you use DoCmd.RunCommand acCmdPrint
so you can specify which tray to print on "property"
 

Cliff67

Registered User.
Local time
Today, 07:42
Joined
Oct 16, 2018
Messages
175
sorry arnelgp I know it sounds silly after using Access for donkeys years I've never used DoCmd.RunCommand acCmdPrint

How do I specify the tray on the property?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:42
Joined
May 7, 2009
Messages
19,175
Code:
Private Sub CmdPrint_Click()
Dim TempRpt As TempVars
Dim TempNo As TempVars
TempVars!TempRpt = Me.ID.Value
TempVars!TempNo = Me.RMANo.Value

On Error GoTo ErrHand
    'Set Application.Printer = Printers("Samsung X4300 Series")
    'Application.Printer.PaperBin = acPRBNLower
    DoCmd.OpenReport ReportName:="Rpt_RMA", View:=acViewPreview, WindowMode:=acHidden
    DoCmd.RunCommand acCmdPrint
    'Set Application.Printer = Nothing
On Error GoTo 0
DoCmd.Close acReport, "Rpt_RMA"
Exit Sub

ErrHand:
strSEM = dfSEM(Err.Number, Err.Description, "Frm_Repair_Main", "CmdPrint_Click")
MsgBox strSEM, vbInformation, "Technical Support and Repairs Database"
Err.Clear
Exit Sub
End Sub
 

Cliff67

Registered User.
Local time
Today, 07:42
Joined
Oct 16, 2018
Messages
175
Code:
Private Sub CmdPrint_Click()
Dim TempRpt As TempVars
Dim TempNo As TempVars
TempVars!TempRpt = Me.ID.Value
TempVars!TempNo = Me.RMANo.Value

On Error GoTo ErrHand
    'Set Application.Printer = Printers("Samsung X4300 Series")
    'Application.Printer.PaperBin = acPRBNLower
    DoCmd.OpenReport ReportName:="Rpt_RMA", View:=acViewPreview, WindowMode:=acHidden
    DoCmd.RunCommand acCmdPrint
    'Set Application.Printer = Nothing
On Error GoTo 0
DoCmd.Close acReport, "Rpt_RMA"
Exit Sub

ErrHand:
strSEM = dfSEM(Err.Number, Err.Description, "Frm_Repair_Main", "CmdPrint_Click")
MsgBox strSEM, vbInformation, "Technical Support and Repairs Database"
Err.Clear
Exit Sub
End Sub
Thanks for that, I stepped through it but once it starts to print it tries to print all the records not just the selected one so I have to cancel the print
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:42
Joined
May 7, 2009
Messages
19,175
you need to add WhereCondition to limitd/filter your report:

DoCmd.OpenReport ReportName:="Rpt_RMA", View:=acViewPreview, WindowMode:=acHidden, WhereCondition:="ID = " & Me!ID
 

Cliff67

Registered User.
Local time
Today, 07:42
Joined
Oct 16, 2018
Messages
175
Thank you arnelgp for your help. That is a lot better than I had the user had to press Ctrl +P to print it off
 

Users who are viewing this thread

Top Bottom