Solved

How to have user set preferred printer

Posted on 2014-02-24
9
749 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

939 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