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

x
?
Solved

setting report and form printer name and settings

Posted on 2004-10-19
11
Medium Priority
?
383 Views
Last Modified: 2008-01-09
I am trying to give my users complete control of printer selection and settings paper source, paper size, orientation, duplex printing) for forms and reports of my Access 2000 MDE database.  I have reasearched into DEVMODE and DEVNAMES but I understand they must be used in design view and can't be used in an MDE file.  I found "On the Fly Pinting" (http://ourworld.compuserve.com/homepages/attac-cg/acgsoft.htm) but it does not support printer settings for MDE files.  I found the following link: http://ourworld.compuserve.com/homepages/attac-cg/acgsoft.htm which shows code for changing the printer but not the settings.  I am planning to link an MDB file located on each computer's local drive to the main MDE file so the user can specify the printer and settings he wants on that machine.  When each report is printed, the table in the MDB file is looked up and the printer is selected and settings set.  Or the user can click another button if he wants to change the printer or settings for one printing.  Any suggestions are requested.  TIA
0
Comment
Question by:thenelson
[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
  • 7
  • 2
11 Comments
 
LVL 6

Expert Comment

by:mcorrente
ID: 12348465
try using the Printers Collection.

Set Application.Printer = Application.Printers([PrinterName in Quotes])
0
 
LVL 6

Expert Comment

by:mcorrente
ID: 12348471
I think earliest version that uses this is Access2000
0
 
LVL 6

Expert Comment

by:mcorrente
ID: 12348579
That will change the default printer for the current session of Access.  The printer properties can also be accessed from this collection.  If you're looking to create a way to allow the user to select his own printer, create a combo box to list them.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Expert Comment

by:mcorrente
ID: 12348684
create the combo box with the following settings:

Name = cboPrinters
Row Source Type = Value List
Row Source = [Leave Blank]
Column Count = 2
Column Widths = 0";4;
Bound Column = 1
List Width = 4"
Limit To List = Yes

Then put the following code in the Load event of the form containing the combo box:

Dim intCounter As Integer
Dim strRowSource As String

For intCounter = 0 To Application.Printers.Count - 1
    strRowSource = strRowSource & CStr(intCounter) & ";" & Application.Printers(intCounter).DeviceName & ";"
Next

Me.cboPrinters.RowSource = strRowSource
0
 
LVL 6

Expert Comment

by:mcorrente
ID: 12348704
That will give you the option to select the printer, and you can bind the combo box to a field to save the setting.  The field will contain the index number of the printer, not the name.  You can then call the printer every time access is opened by running the following code:

set application.printer = application.printers([Index Number W/Out Brackets])
0
 
LVL 6

Expert Comment

by:mcorrente
ID: 12348721
as far as the other printer settings, you should be able to find them through the printers collection properties.  Look up "Printers Collection" in the Visual Basic help file.
0
 
LVL 39

Author Comment

by:thenelson
ID: 12349212
mcorrente , thanks for the suggestions but I think the "Printers Collection" became available with Access 2002 and 2003.  I could not find any reference to it in 2000.  I tried building the combo box form/code but it failed at the line:
For intCounter = 0 To Application.Printers.Count - 1  
with the error message that "Printers" method or data member not found.

If I don't find another answer, I may have to upgrade to 2003.
0
 
LVL 6

Expert Comment

by:mcorrente
ID: 12349367
hmmm.... you might be right, come to think of it.  I know for a fact it runs on 2002, but I believe I had to work around it in 2000.  Well... I know this solution works for later versions.  Hopefully someone else can help you with 2000.
0
 
LVL 39

Author Comment

by:thenelson
ID: 12351957
Searching the web, I came up with a solution to my original question:

To change default printer:
Use the code at: http://www.attcanada.net/~kallal.msn/msaccess/msaccess.html
(This will not work in Office XP running Windows XP so for a universal solution, you would wantto check the Access version and use printers collection for Office 2002 or 2003)

To set and save printer settings:   (from: http://www.codeguru.com/forum/showthread.php?s=&threadid=220382)
'display printing preferences:
Shell ("rundll32 printui.dll,PrintUIEntry /e /n" Chr(22)  & strPrinterName & Chr(22))
'Store printer settings into a file:
Shell (rundll32 printui.dll,PrintUIEntry /Ss /n Chr(22)  & strPrinterName & Chr(22)  /a Chr(22)  & strFileName & Chr(22))

To set printer settings:
'Save previous settings:
Shell (rundll32 printui.dll,PrintUIEntry /Ss /n Chr(22)  & strPrinterName & Chr(22)  /a Chr(22)  & strPrevFileName & _ Chr(22))
'Recall (set) printer settings from a file:
Shell (rundll32 printui.dll,PrintUIEntry /Sr /n Chr(22)  & strPrinterName & Chr(22)  /a Chr(22)  & strFileName & Chr(22))
'Recall previous settings
Shell (rundll32 printui.dll,PrintUIEntry /Sr /n Chr(22)  & strPrinterName & Chr(22)  /a Chr(22)  & strPrevFileName & _ Chr(22))
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 12464089
Closed, 500 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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.
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…

604 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