Solved

Printing a Form in Access with parameters

Posted on 2011-03-25
5
333 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

828 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