Solved

Printing a Form in Access with parameters

Posted on 2011-03-25
5
330 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Grrrreat!

;-)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Subform "Column Choose" Functionality 3 19
Text Value from Time 3 21
ms/access report does not open query 20 31
Resize text 4 14
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
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…
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now