Solved

Select Default Printers for Specific Reports

Posted on 2011-09-21
10
261 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
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

792 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