Solved

How to have user set preferred printer

Posted on 2014-02-24
9
793 Views
Last Modified: 2014-03-06
I am generating a batch of reports in a client application.  The client has split job functions such that the person generating the reports is not the one that will be reviewing them.  The person that is reviewing the reports is in a different department, possibly on a different floor and definitely has a different default printer than the person initiating the reports.

I would like to provide the person generating the reports with the ability to select the output printer to be used for the entire batch of reports that will be generated, once and only once prior to generating the reports.  The entire batch of reports will then go to the selected printer without prompting the initiating user to select the output printer again.

Selecting the output printer for the batch of reports should not change the default printer of the initiator.
0
Comment
Question by:mlcktmguy
[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
  • 5
  • 4
9 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39883597
2003 has the Printer object. You could set that when needed like this:

Application.Printer = "Your Printer"

"Your Printer" is the Windows printer name, so you have to be careful how to get that. You can show a listing of printers to the user in a combo, and let them select it:

Dim prt As Printer
Dim sPrinters As String

For Each prt in Application.Printers
  sPrinters = sPrinters & ";" & prt.Name  
Next

Me.YourCombo.RowSourceType= ValueList
Me.YourCombo.RowSource = sPrinters

You'd then set the printer like this:

Application.Printer = Me.YourCombo
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 39889808
Thank you
I setup your code on a form with a combo box.

I had to change prt.name to prt.devicename
and
Me.YourCombo.RowSourceType= ValueList to Me.YourCombo.RowSourceType= "Value List"

No bg deal on either of those.  I'm just pointing it ou in case someone is following this to use later.

After those changes, I put up the combo box and make a selection.

I get a mismatched type error on the statement:

Application.Printer = Me.YourCombo

I also tried

Set Application.Printer = Me.cmbPrinters    and got the same error

Any ideas on what is causing this error or how to resolve it?
0
 
LVL 84
ID: 39890222
What's the name of your Combo?

You may need to refer to the Column:

Application.Printer = Me.YourCombo.Column(0)

Where "YourCombo" is the name of the Combo ...
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 1

Author Comment

by:mlcktmguy
ID: 39890270
Thta got me to a different error '424' object required.

Just wondering if there is there a reference I need to set for this?

I setup a very simple test form with the combo box and a button to press to ste the printer based on what is selected in the combo box.

Here is all of my code behind the form:

Option Compare Database

Option Explicit

Private Sub btnSelect_Click()

'Debug.Print Me.cmbPrinters.Column(0)

Application.Printer = Me.cmbPrinters.Column(0)



End Sub

Private Sub Form_Load()
'
'Application.Printer = "Your Printer"
'
'"Your Printer" is the Windows printer name, so you have to be careful how to get that. You can show a listing of printers to the user in a combo, and let them select it:
'
Dim prt As Printer
Dim sPrinters As String
sPrinters = ""

For Each prt In Application.Printers
    If sPrinters = "" Then
        sPrinters = prt.DeviceName
    Else
        sPrinters = sPrinters & ";" & prt.DeviceName
    End If
  
Next

Me.cmbPrinters.RowSourceType = "Value List"
Me.cmbPrinters.RowSource = sPrinters

End Sub

Open in new window

0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 39906403
Still hoping for a suggestion/followup
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39906613
Sorry ...

This line:

Application.Printer = Me.cmbPrinters.Column(0)

Should be this:

Application.Printer = Application.Printers( Me.cmbPrinters.Column(0))
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 39908325
Yes, that worked.  Is there a way to show them which printer is currently set as the Aplication.Prnter so they can decide whether they need to change it?

I tried setting application.Printer to a string but that obviously didn't work.

I'd like to show it on the report request screen, so they know where the output is going, since it may not be the default printer since they changed it.
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39909053
Application.Printer.DeviceName will show you the printer currently selected, so you do this:

Me.txCurrentPrinterName = Application.Printer.DeviceName
0
 
LVL 1

Author Closing Comment

by:mlcktmguy
ID: 39909453
Perfect, thank you very much
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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.
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.
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…

730 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