Solved

setting report and form printer name and settings

Posted on 2004-10-19
11
380 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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