Solved

How to have user set preferred printer

Posted on 2014-02-24
9
723 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
  • 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
 
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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

708 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

12 Experts available now in Live!

Get 1:1 Help Now