Solved

Printing a Form in Access with parameters

Posted on 2011-03-25
5
332 Views
Last Modified: 2013-11-27
I would like to use VBA code to print a form from Access 2007.  I only want the 1st page to print in Landscape and would like to set the margins in the code as well.  I am using Docmd.Printout which does print but not with the specifications I stated above.  Does anyone know how I can use the settings?
0
Comment
Question by:marku24
  • 3
  • 2
5 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35215236
Forms are for Data entry, *Reports* are for Printing.

What you are asking for is unique.
" I only want the 1st page to print in Landscape"
...suppose the "data" on page 1 spans more than 1 page?
...What of the remaining pages?

"set the margins in the code as well."
Margins for the first page?.. The remaining pages?..., both?

Again, you will have much more control over this if you used a Report.

JeffCoachman
0
 

Author Comment

by:marku24
ID: 35215254
I am very familiar with reports.  Just in this once instance I need to print the first page of a multi page report from the form.  settings would be for all pages even though I am only printing the first page.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 250 total points
ID: 35215375
Well to set the margins you would do something like this on the open event of the form:

     Me.Printer.LeftMargin = 1440
     Me.Printer.TopMargin = 1440
     Me.Printer.RightMargin = 1440
     Me.Printer.BottomMargin = 1440

Because most measurements are in Twips, 1440 twips =1 inch.
So the code above will set the margins to 1 inch.

To set the Orientation to landscape use:
Me.Printer.Orientation=acPRORLandscape

Does this work for what you need?

Jeffcoachman

0
 

Author Closing Comment

by:marku24
ID: 35215563
This worked great.  I just added this:
DoCmd.PrintOut acPrintAll, 1, 1

to only print the first page of the screen print
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35217237
Grrrreat!

;-)
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access 2016 - query 23 59
Trying to open FORM in specific record !! 6 44
Archiving Access table older than 6 months 9 39
is Microsoft Access going to Die? 9 46
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

770 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