473,722 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printer and Printing Tips

ADezii
8,834 Recognized Expert Expert
Recently, there seems to be several questions specifically related to Printers and changing Printing characteristics for Forms and Reports. For this reason alone, I decided to dedicate this week's Tip to these Topics. The Tip will actually consist of several Tips which I feel are very useful for all Users, from Newbies to Experts. In order to utilize the code contained within these Tips, you must have Access 2002 or later.
  1. How can I generate a List of available Printers?
    Expand|Select|Wrap|Line Numbers
    1. 'Prints a list of available Printers and thier Ports
    2. 'to the Immediate Window
    3. Dim prn As Printer
    4.  
    5. For Each prn In Application.Printers
    6.   Debug.Print prn.DeviceName & " on " & prn.Port
    7. Next prn
  2. How can I find the characteristics of the current Window's Default Printer?
    Expand|Select|Wrap|Line Numbers
    1. 'Lists specific characteristics of the Current Printer
    2. With Application.Printer
    3.   Debug.Print "Current Printer   : " & .DeviceName
    4.   Debug.Print "Device Driver Name: " & .DriverName
    5.   Debug.Print "Port Assignment   : " & .Port
    6. End With
  3. How do I fill a Combo Box with a list of Installed Printers?
    Expand|Select|Wrap|Line Numbers
    1. 'Fills a Combo Box with a list of Installed Printers
    2. Dim prn As Printer, cbo As ComboBox
    3. Dim strText As String
    4.  
    5. Set cbo = Me![cboPrinters]
    6.  
    7. 'Clear the control's list.
    8. cbo.RowSource = vbNullString
    9. cbo.RowSourceType = "Value List"
    10.  
    11. 'Set up three columns
    12. cbo.ColumnCount = 3
    13. cbo.ColumnWidths = "3in;1in;1in"
    14. cbo.Width = 5 * 1440    '5 inches (measured in Twips)
    15.  
    16.  
    17. 'Bind to the DeviceName column (1)
    18. cbo.BoundColumn = 1
    19.  
    20. For Each prn In Application.Printers
    21.   strText = prn.DeviceName & ";" & prn.DriverName & _
    22.             ";" & prn.Port
    23.   cbo.AddItem strText
    24. Next prn
  4. How do I change the Default Printer?
    Expand|Select|Wrap|Line Numbers
    1. 'Changes the Default Printer, then resets it to the original Printer.
    2. 'This will only work if the report is set up to Print to the Default
    3. 'Printer
    4.  
    5. Set Application.Printer = Application.Printers("Acrobat PDFWriter")
    6.   DoCmd.OpenReport "<Your Report Name>", acViewNormal, , , acWindowNormal
    7.  
    8. 'Reset the Default Printer back to the way it was
    9. Set Application.Printer = Nothing
  5. How do I print a Report to a specific device?
    Expand|Select|Wrap|Line Numbers
    1. 'The following code will Print rptInvoices to the Acrobat PFDWriter Printer
    2. Dim rpt As Report
    3.  
    4. DoCmd.OpenReport "rptInvoices", View:=acViewPreview, WindowMode:=acHidden
    5.  
    6. Set rpt = Reports("rptInvoices")
    7. Set rpt.Printer = Application.Printers("Acrobat PFDWriter")
    8.  
    9. DoCmd.OpenReport "rptInvoices"
    10. DoCmd.Close acReport, "rptInvoices"
  6. How can I modify Printer characteristics for a Form or Report?
    Expand|Select|Wrap|Line Numbers
    1. 'Open rptInvoices in Design view, change 3 of its Properties
    2. 'Print the report, and then close the report.
    3.  
    4. Const conReport As String = "rptInvoices"
    5.  
    6. DoCmd.OpenReport conReport, View:=acViewPreview, WindowMode:=acHidden
    7.  
    8. 'Force the printer to look to the upper bin for paper, print on
    9. 'Monarch-size envelopes, and Print two copies, set orientation to
    10. 'Landscape
    11. With Reports(conReport).Printer
    12.   .PaperBin = acPRBNUpper
    13.   .PaperSize = acPRPSEnvMonarch
    14.   .Copies = 2
    15.   .Orientation = acPRORLandscape
    16.   .Duplex = acPRDPVertical
    17.   .PrintQuality = acPRPQMedium
    18. End With
    19.  
    20. 'Now print the report.
    21. DoCmd.OpenReport conReport
    22. DoCmd.Close acReport, conReport
  7. How do I change the Layout characteristics for a Form or Report?
    Expand|Select|Wrap|Line Numbers
    1. Const conReport As String = "rptInvoices"
    2. Const conTwipsPerInch As Long = 1440
    3.  
    4. DoCmd.OpenReport conReport, View:=acViewPreview, WindowMode:=acHidden
    5.  
    6. 'Modify layout information. set up margins, columns, and
    7. 'print only data.
    8. With Reports(conReport).Printer
    9.   .LeftMargin = 0.5 * conTwipsPerInch
    10.   .RightMargin = 0.5 * conTwipsPerInch
    11.   .TopMargin = 1 * conTwipsPerInch
    12.   .BottomMargin = 1 * conTwipsPerInch
    13.   .ItemsAcross = 2
    14.   .ItemLayout = acPRHorizontalColumnLayout
    15.   .DefaultSize = False
    16.   .ItemSizeWidth = 3 * conTwipsPerInch
    17.   .ColumnSpacing = 0.1 * conTwipsPerInch
    18.   .DataOnly = True
    19. End With
    20.  
    21. DoCmd.OpenReport conReport
    22. DoCmd.Close acReport, conReport
Nov 19 '07 #1
4 16814
missimma
5 New Member
I'm Immaculata
Thanks for what you just wrote, i got some help from here. But i'm currently working on a program for a school. My problem is tabularizing the results of my recordsets. i.e. I created a recordset, it got the data from the database and i want to print the output in a tabular form. Please how do i do this?
Jan 15 '08 #2
ADezii
8,834 Recognized Expert Expert
I'm Immaculata
Thanks for what you just wrote, i got some help from here. But i'm currently working on a program for a school. My problem is tabularizing the results of my recordsets. i.e. I created a recordset, it got the data from the database and i want to print the output in a tabular form. Please how do i do this?
I'm not exactly sure of what you are looking for, but this code will write the First Name, Last Name, and Address Fields of an Employees Table to a Text File (Recordset.txt) in the C:\Test\ Directory. The data will be Tabular and neatly formatted.
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As DAO.Database, MyRS As DAO.Recordset
  2.  
  3. Set MyDB = CurrentDb()
  4. Set MyRS = MyDB.OpenRecordset("Select * From Employees", dbOpenSnapshot)
  5.  
  6. Open "C:\Test\Recordset.txt" For Output As #1
  7.  
  8. Do While Not MyRS.EOF
  9.   Print #1, MyRS![FirstName]; Tab(20); MyRS![LastName]; Tab(40); MyRS![Address]
  10.   MyRS.MoveNext
  11. Loop
  12.  
  13. Close #1
  14.  
  15. MyRS.Close
  16. Set MyRS = Nothing
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. Nancy              Albericih           507 - 20th Ave. E. Moyamensing Avenue
  2. Andrew             Fuller              908 W. Capital Waykk
  3. Janet              Leverling           722 Moss Bay Blvd.
  4. Margaret           Peacock             4110 Old Redmond Rd.
  5. Steven             Buchanan            14 Garrett Hill
  6. Michael            Suyama              Coventry House and Miner Rd.
  7. Laura              Callahan            4726 - 11th Ave. N.E.
  8. Anne               Dodsworth           7 Houndstooth Rd.
  9. Robert             King                Edgeham Hollow Road
  10. Fred               Buchanan            14 Garrett Hill
Jan 17 '08 #3
altinM
2 New Member
hi

i have a problem when i want to print the following message comes up: can't print or preview the page because the page size you selected is larger than 22.75 inches - any one can help me please
Jan 23 '08 #4
ADezii
8,834 Recognized Expert Expert
hi

i have a problem when i want to print the following message comes up: can't print or preview the page because the page size you selected is larger than 22.75 inches - any one can help me please
What exactly are you trying to Print?
Jan 23 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3193
by: Daniel Iwan | last post by:
Hello everyone! I have a problem with using TCanvas Printer and network printer HP LaserJet It print just first page and throws blank all the rest. WinNT with Borland Builder 5. All works fine with my HP 3820 with USB printer (WinXP)
1
1499
by: Geir Baardsen | last post by:
Hi! I would like to halt the code while a report I send to printer is printing. Then when printer has done its job I'll let the code continues. Anybody that know how this is done in ms access 2000? Me.Name
2
1270
by: tom thorp | last post by:
I'm currently working on my first complex VB.Net / Winforms application where I'm not using CR to print my Invoices, but have written using PrintDoc My problem is that on my dev machine, everything works fine. When I deploy it on the production server, the graphic and lines print fine. But no text prints. If I print to a PDF creator on the server, the fonts appear just fine. I've verified that the font's I'm using are also on the server ...
3
6315
by: Mika M | last post by:
Hi all! I have made an application for printing simple barcode labels using PrintDocument object, and it's working fine. Barcode printer that I use is attached to the computer, and this computer has drivers installed for this printer, and this printer is shared for the network. Question 1:
7
2043
by: Jean Paul Mertens | last post by:
Hello, Is there a way to send a string of text to a generic tekst printer under ..NET. Somethings as in the good old days File f = Open("LPT1"); f.Writeline("Blablabla"); The goal is to use an old lineprinter as a log printer printing out each line (incomming allert) at a time without having to build a whole page
2
3163
by: Larry L | last post by:
Hi guys, been a while since I've been on the group, glad to see some regulars are still around! I've got an app that outputs a scale model plan to a printer, printing to a lettersize or a4 sheet of paper. The output is exactly to scale, and if cut and assembled will produce a miniature version of the drawn object. The program is very stable and I rarely get support calls from my users, however I DO get a lot of folks who've downloaded...
2
1485
by: dwadish | last post by:
Hi Guys I am Using VB.Net for creating Windows Applications. and I have project now about a textile shop and need Printing the daily book. and I have no experience with printing technologies. and i need to print items listed in a list view control. any one can help me!? Thanx in advance
1
1230
by: =?Utf-8?B?Sm9jaw==?= | last post by:
My Brother printer receives two of the same print jobs when I click PRINT - however, the first job says it is deleting, but it never does and stops printer printing. This happens on WORD. To print, I have to reboot, start again, and then it only prints one doc before it returns to the deleting message and jams. Help! -- Jock Kennedy
0
929
by: ahok80 | last post by:
i want to know code print subreport in vb.net. when i print subreport, why my printer printing main report?
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.