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 16352
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 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
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?
Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
2 posts
views
Thread by Daniel Iwan |
last post: by
|
1 post
views
Thread by Geir Baardsen |
last post: by
|
2 posts
views
Thread by tom thorp |
last post: by
|
3 posts
views
Thread by Mika M |
last post: by
|
7 posts
views
Thread by Jean Paul Mertens |
last post: by
|
2 posts
views
Thread by Larry L |
last post: by
| |
1 post
views
Thread by =?Utf-8?B?Sm9jaw==?= |
last post: by
| | | | | | | | | | | |