Access XP - Changing a Printer Designation in PrintRecord Command Button

A

Abby

I want to put code in the Event Procedure of my Print
Record command button that will change the printer from
the current printer to a specific printer, print the
record and then switch the printer back to the original
printer. I found the following code:

Sub SwitchPrinter()
Dim strActivePrinter as String
strActivePrinter = Application.ActivePrinter
Application.ActivePrinter = " .... " ' I put the full name
of printer I want to use (including the path)
ActiveDocument.PrintOut
Application.ActivePrinter = strActivePrinter
End Sub

I also have code from Word which I have used in a macro to
print to a specific printer:

Dim currPrinter as string
currPrinter = ActivePrinter
ActivePrinter = "\\RPFS1\West"
ActiveDocument.PrintOut
ActivePrinter = currPrinter
End Sub

And of course the code that the PrintRecord has already in
it:

Private Sub cmdPrintRecord_Click()
On Error GoTo Err_cmdPrintRecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, ,
acMenuVer70
DoCmd.PrintOut acSelection
Exit_cmdPrintRecord_Click:
Exit Sub
Err_cmdPrintRecord_Click:
MsgBox Err.Description
Resume Exit_cmdPrintRecord_Click
End Sub

How do I create the code (from these pieces) to accomplish
my goal?

Thank you.
 
S

SA

Abby:

There is no "Active Printer" property of the Application object in Access.
Access uses a printer object. So the code might look like this:

Dim objPrinter As Printer
Dim objOrigPrinter as Printer
objOrigPrinter = Application.Printer
For Each objPrinter In Application.Printers
If objPrinter.DeviceName = "MyPrinterOfChoice" Then
Application.Printer = objPrinter
End If
Next

'Do your output here

Application.Printer = objOrigPrinter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top