Solved

Printing a Form in Access with parameters

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

733 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