Solved

setting report and form printer name and settings

Posted on 2004-10-19
11
374 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

707 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

15 Experts available now in Live!

Get 1:1 Help Now