Printer will not work with access

M

MikeCCC

I know exactly how to use access but maybe I have a system problem.The code
below works once (and once only) then give a "printer not known" box.

Any suggestions

Function ChangePrinter(rptToChange As String, rptPrinter As String)
Dim rpt1 As Report, rpt2 As Report
DoCmd.OpenReport rptToChange, acViewDesign
DoCmd.OpenReport rptPrinter, acViewDesign
Set ReportA = Report(rptChange)
Set ReportB = Report(Printer)
rpt1.PrtDevNames = rpt2.PrtDevNames
DoCmd.Close acReport, rptPrinter,
DoCmd.OpenReport rptToChange, acViewPreview
End Function
 
W

Wayne-in-Manchester

Far be it for me to tell anyone anything who knows how to use access
anything, it may be a good idea to save the printer (save to a module). As
you will obviously know another way of doing this would be to use the default
printer (when you design the output of the report). To save the printer use
“acSaveNoâ€

Function ChangePrinter(rptToChange As String, rptPrinter As String)
Dim rpt1 As Report, rpt2 As Report
DoCmd.OpenReport rptToChange, acViewDesign
DoCmd.OpenReport rptPrinter, acViewDesign
Set ReportA = Report(rptChange)
Set ReportB = Report(Printer)
rpt1.PrtDevNames = rpt2.PrtDevNames
DoCmd.Close acReport, rptPrinter, acSaveNo
DoCmd.OpenReport rptToChange, acViewPreview
End Function

Hope this helps with your system problem
 
A

Albert D.Kallal

You don't mention what version\ of ms-access.

In access 2002 and later, there is a built in printer object, and it lets
you switch the printer with ease.

You can use:

Set Application.Printer = Application.Printers("HP LaserJet Series II")

So, to save/switch, you can use:

dim strDefaultPrinter as string

' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName

' switch to printer of your choice:

Set Application.Printer = Application.Printers("HP LaserJet Series II")

do whatever. --- print your reprots...etc...

Swtich back.

Set Application.Printer = Application.Printers(strDefaultPrinter)


If you are using a earlier versions, then you can use my lightweight printer
switch code here:

http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html

So, I would suggest you change your approach to printer switching to one of
the above.....
 

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