Solved

Select Default Printers for Specific Reports

Posted on 2011-09-21
10
258 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 - Access MVP) 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now