473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,387 developers and data experts.

Printer and Printing Tips

ADezii
8,834 Expert 8TB
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 16739
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 Expert 8TB
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
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 Expert 8TB
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
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...
1
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...
2
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,...
3
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...
7
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...
2
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...
2
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...
1
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,...
0
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.