Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to have user set preferred printer

Posted on 2014-02-24
9
Medium Priority
?
876 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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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 85
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
Technology Partners: 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 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 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…
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…

636 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