[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Select Default Printers for Specific Reports

Posted on 2011-09-21
10
Medium Priority
?
267 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

656 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