Solved

Select Default Printers for Specific Reports

Posted on 2011-09-21
10
262 Views
Last Modified: 2012-05-12
I am completing a project and I cannot figure out how to assign specific printers to reports. I will be printing two types of reports . One will be a regular report and will be directed to a laserjet printer. The other report will be directed to a Zebra label printer. This project will be distrubuted with run-time so the full version of Access will not be available.
I have a company master table that has two fields labeled ReportsPrinter and LabelPrinter. I want to create a combobox that will populate with the printers available on the user's workstation. Then the user will be able to select the printer they wish to use for reports and labels. When I call the report I want to pull the printer name from the Company Master fields and send the report / labels to the correct printer.
0
Comment
Question by:rodneygray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 75
ID: 36577905

  You can use this more or less
    Dim prt As Printer
   
    With Application
        Set prt = .Printer  'Save current Default Printer
        .Printer = Application.Printers("YourSpecialPrinterNameHere")
         DoCmd.OpenReport "SomeReportName", acViewNormal      
        .Printer = prt      'Put back Default Printer        
    End With

mx
0
 
LVL 75
ID: 36577912

You can do this to list printers:


    Dim x
    For x = 0 To Application.Printers.Count - 1
        Debug.Print Application.Printers.Item(x).DeviceName & "  " & x
    Next x

You could fill a combo box RowSource with this, and RowSource Type would be Value List.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36577989
Unless I am misunderstanding something you can set the report to always print to a specific printer.

Open the report in design view
In Page setup, click the "Page" tab
Under: "Printer for rtpXXXX", select:  "Use Specific Printer"
Then click the printer button and select the printer you need.
Click OK, save the report.
Compact/repair the DB for good measure, then test.

JeffCoachman
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75
ID: 36578008
I suspect the OP means in code ...

mx
0
 
LVL 1

Author Comment

by:rodneygray
ID: 36578036
Boag2000: DB will be distributed as runtime. I need a method to allow users to select printer to use for reports and labels. I will store that value in the company table. On the company form, I will have two fields, ReportPrinter and LabelPrinter. Program will then be able to lookup printer value from Company table and print correct report/label to specified printer.
DatabaseMX: I am trying to implement your code now.
0
 
LVL 1

Author Comment

by:rodneygray
ID: 36578043
DatabaseMX: How do I populate a comboBox with the printer values?
0
 
LVL 1

Author Comment

by:rodneygray
ID: 36578061
DatabaseMX: Should I make the "filling a comboBox" via VBA another question? The only method that occurs to me is to create a table, populate the table with printer values and then set source of comboBox to the table. I would have to repopulate the table each time the Company form was opened.
0
 
LVL 1

Author Comment

by:rodneygray
ID: 36578117
DatabaseMX: Used the following code to populate with available printers.
    Me.cmboReportPrinter.RowSource = ""
    For Each prt In Application.Printers
        Me.cmboReportPrinter.AddItem prt.DeviceName
    Next
0
 
LVL 12

Expert Comment

by:danishani
ID: 36578123
Hope this articles will work for you:
http://support.microsoft.com/kb/319317

Or this solution provided by Allen Browne:
http://allenbrowne.com/AppPrintMgt.html

Hope this helps,
Daniel
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 36578221


"DatabaseMX: Used the following code to populate with available printers."

There you go.  So, you just need this now:

Private Sub btnPrint_Click()
    With Application
        Set prt = .Printer  'Save current Default Printer
        .Printer = Application.Printers(Me.YourPrinterComboBoxName)
         DoCmd.OpenReport "SomeReportName", acViewNormal
        .Printer = prt      'Put back Default Printer
    End With
End Sub
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question