Solved

setting report and form printer name and settings

Posted on 2004-10-19
11
378 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
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

830 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