Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Printing a Form in Access with parameters

Posted on 2011-03-25
5
Medium Priority
?
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

610 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