?
Solved

How to have user set preferred printer

Posted on 2014-02-24
9
Medium Priority
?
854 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

764 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