Setting up Printing to a Printer that you don't have connected? (1 Viewer)

Minty

AWF VIP
Local time
Today, 09:39
Joined
Jul 26, 2013
Messages
10,369
I'm not sure how to go about this, I need to create a modified copy of a report that is printed to a specific (Non default) Label printer.

I don't have the printer in question connected and it isn't available as a share on our network.

If I copy the report - and then edit it, the printer set up defaults to my standard A4 printer. How can I force Access to use the named printer, without phsyically
trying to hook up to it.
 

isladogs

MVP / VIP
Local time
Today, 09:39
Joined
Jan 14, 2017
Messages
18,211
Hi Minty

Years ago I had the same problem but I can't remember how I solved it

Possibly something like this:
Code:
Dim strPrinter As String
strPrinter = "MyLabelPrinter"
Set Application.Printer = Application.Printers(strPrinter)

Have a look at Allen Browne's select printer utility which may do what you want:
http://www.allenbrowne.com/AppPrintMgt.html
 

Minty

AWF VIP
Local time
Today, 09:39
Joined
Jul 26, 2013
Messages
10,369
Hi Colin,

Thanks - I think that will help.

Or at least give me something to fiddle with for a day or two before throwing my toys out of the pram and going and getting a printer to hook up.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:39
Joined
May 7, 2009
Messages
19,230
Will this help

DoCmd.RunCommand acCmdPrintSelection
 

isladogs

MVP / VIP
Local time
Today, 09:39
Joined
Jan 14, 2017
Messages
18,211
I think all you need to know is the name of the printer as it will appear in the string. Presumably someone onsite will be able to tell you that.

I found the report where I had a similar problem - it was for staff ID cards:



I've just tried specifying the printer in the Report Open event but got error 5 when I try to run the report.
So I added error handling code:

Code:
Private Sub Report_Open(Cancel As Integer)

On Error GoTo Err_Handler

    Dim strPrinter As String
    strPrinter = "K3CardPrinter" '<== do I need spaces here?
    Set Application.Printer = Application.Printers(strPrinter)
    
Exit_Handler:
    Exit Sub
    
Err_Handler:
    If Err = 5 Then Resume Next
    MsgBox "Error " & Err.Number & " in Report_Open procedure : " & Err.Description, vbExclamation, "Error opening report"
    Resume Exit_Handler
End Sub

I can now design/ run & print the report without having that printer connected.
Now all I need to do is test it with the specified printer connected!

No idea how to specify the USB port however
 

Attachments

  • Capture.PNG
    Capture.PNG
    7.6 KB · Views: 203

Minty

AWF VIP
Local time
Today, 09:39
Joined
Jul 26, 2013
Messages
10,369
Thanks Colin.

That was sort of the route I was trying to get to, but time wasn't on my side today - so I have taken a "work around" nee Cludge, to solve it on a temporary basis today.

I have a phrase often heard around here: "I fec**ng hate working on labels" :rolleyes:
 

Users who are viewing this thread

Top Bottom