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. - How can I generate a List of available Printers?
- 'Prints a list of available Printers and thier Ports
-
'to the Immediate Window
-
Dim prn As Printer
-
-
For Each prn In Application.Printers
-
Debug.Print prn.DeviceName & " on " & prn.Port
-
Next prn
- How can I find the characteristics of the current Window's Default Printer?
- 'Lists specific characteristics of the Current Printer
-
With Application.Printer
-
Debug.Print "Current Printer : " & .DeviceName
-
Debug.Print "Device Driver Name: " & .DriverName
-
Debug.Print "Port Assignment : " & .Port
-
End With
- How do I fill a Combo Box with a list of Installed Printers?
- 'Fills a Combo Box with a list of Installed Printers
-
Dim prn As Printer, cbo As ComboBox
-
Dim strText As String
-
-
Set cbo = Me![cboPrinters]
-
-
'Clear the control's list.
-
cbo.RowSource = vbNullString
-
cbo.RowSourceType = "Value List"
-
-
'Set up three columns
-
cbo.ColumnCount = 3
-
cbo.ColumnWidths = "3in;1in;1in"
-
cbo.Width = 5 * 1440 '5 inches (measured in Twips)
-
-
-
'Bind to the DeviceName column (1)
-
cbo.BoundColumn = 1
-
-
For Each prn In Application.Printers
-
strText = prn.DeviceName & ";" & prn.DriverName & _
-
";" & prn.Port
-
cbo.AddItem strText
-
Next prn
- How do I change the Default Printer?
- 'Changes the Default Printer, then resets it to the original Printer.
-
'This will only work if the report is set up to Print to the Default
-
'Printer
-
-
Set Application.Printer = Application.Printers("Acrobat PDFWriter")
-
DoCmd.OpenReport "<Your Report Name>", acViewNormal, , , acWindowNormal
-
-
'Reset the Default Printer back to the way it was
-
Set Application.Printer = Nothing
- How do I print a Report to a specific device?
- 'The following code will Print rptInvoices to the Acrobat PFDWriter Printer
-
Dim rpt As Report
-
-
DoCmd.OpenReport "rptInvoices", View:=acViewPreview, WindowMode:=acHidden
-
-
Set rpt = Reports("rptInvoices")
-
Set rpt.Printer = Application.Printers("Acrobat PFDWriter")
-
-
DoCmd.OpenReport "rptInvoices"
-
DoCmd.Close acReport, "rptInvoices"
- How can I modify Printer characteristics for a Form or Report?
- 'Open rptInvoices in Design view, change 3 of its Properties
-
'Print the report, and then close the report.
-
-
Const conReport As String = "rptInvoices"
-
-
DoCmd.OpenReport conReport, View:=acViewPreview, WindowMode:=acHidden
-
-
'Force the printer to look to the upper bin for paper, print on
-
'Monarch-size envelopes, and Print two copies, set orientation to
-
'Landscape
-
With Reports(conReport).Printer
-
.PaperBin = acPRBNUpper
-
.PaperSize = acPRPSEnvMonarch
-
.Copies = 2
-
.Orientation = acPRORLandscape
-
.Duplex = acPRDPVertical
-
.PrintQuality = acPRPQMedium
-
End With
-
-
'Now print the report.
-
DoCmd.OpenReport conReport
-
DoCmd.Close acReport, conReport
- How do I change the Layout characteristics for a Form or Report?
- Const conReport As String = "rptInvoices"
-
Const conTwipsPerInch As Long = 1440
-
-
DoCmd.OpenReport conReport, View:=acViewPreview, WindowMode:=acHidden
-
-
'Modify layout information. set up margins, columns, and
-
'print only data.
-
With Reports(conReport).Printer
-
.LeftMargin = 0.5 * conTwipsPerInch
-
.RightMargin = 0.5 * conTwipsPerInch
-
.TopMargin = 1 * conTwipsPerInch
-
.BottomMargin = 1 * conTwipsPerInch
-
.ItemsAcross = 2
-
.ItemLayout = acPRHorizontalColumnLayout
-
.DefaultSize = False
-
.ItemSizeWidth = 3 * conTwipsPerInch
-
.ColumnSpacing = 0.1 * conTwipsPerInch
-
.DataOnly = True
-
End With
-
-
DoCmd.OpenReport conReport
-
DoCmd.Close acReport, conReport
4 16814
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?
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. -
Dim MyDB As DAO.Database, MyRS As DAO.Recordset
-
-
Set MyDB = CurrentDb()
-
Set MyRS = MyDB.OpenRecordset("Select * From Employees", dbOpenSnapshot)
-
-
Open "C:\Test\Recordset.txt" For Output As #1
-
-
Do While Not MyRS.EOF
-
Print #1, MyRS![FirstName]; Tab(20); MyRS![LastName]; Tab(40); MyRS![Address]
-
MyRS.MoveNext
-
Loop
-
-
Close #1
-
-
MyRS.Close
-
Set MyRS = Nothing
OUTPUT: -
Nancy Albericih 507 - 20th Ave. E. Moyamensing Avenue
-
Andrew Fuller 908 W. Capital Waykk
-
Janet Leverling 722 Moss Bay Blvd.
-
Margaret Peacock 4110 Old Redmond Rd.
-
Steven Buchanan 14 Garrett Hill
-
Michael Suyama Coventry House and Miner Rd.
-
Laura Callahan 4726 - 11th Ave. N.E.
-
Anne Dodsworth 7 Houndstooth Rd.
-
Robert King Edgeham Hollow Road
-
Fred Buchanan 14 Garrett Hill
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
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?
Sign in to post your reply or Sign up for a free account.
Similar topics |
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)
|
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
|
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
...
|
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:
|
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
| |
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...
|
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
|
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
|
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?
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |