Solved

vba to open a query in print preview mode but in landscape

Posted on 2009-05-15
11
2,327 Views
Last Modified: 2012-05-07
I have a qryResults which I want to run from a form button and have it open but then look at it printpreview mode like

    DoCmd.OpenQuery "qryResults", acViewPreview, acEdit

But how do I get it into landscape through vba and is there a shrink to fit as in Excel
0
Comment
Question by:PeterWhitts
[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
  • 5
  • 3
  • 3
11 Comments
 
LVL 75
ID: 24397643
Landscape mode if a printing property, not a preview property. Basically, a query opens in print preview as a datasheet.  From here, you can do File>>Page Setup ... Landscape, etc.  

mx
0
 
LVL 1

Author Comment

by:PeterWhitts
ID: 24397978
But I want to look at my wide datasheet in landscape mode so how can I code  for the File>>Page Setup ... Landscape...is there a send keys for example?
0
 
LVL 75
ID: 24398080
Sorry ... I was mistaken.  When you use the DoCmd.OpenQuery "somename", acPreview

it is not opened in datasheet view.  So, I see what you are trying to do. Off hand, I don't know how you can do this.  I tried opening a query in preview ... using Page Setup to set to Landscape and then saved the query ... but, when I reopened it ... it was still in Portrait mode.

mx

0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 24398525
Howdo Peter, try setting the orientation on the printer

eg

    Application.Printer.Orientation = acPRORLandscape
    DoCmd.OpenQuery "qryResults", acViewPreview

0
 
LVL 1

Author Closing Comment

by:PeterWhitts
ID: 31582010
Cool answer...thanks RR
0
 
LVL 1

Author Comment

by:PeterWhitts
ID: 24399511
Works in XP but as an after thought....is there an equivalent for version 2000 as Application.Printer gives a compile error "Method or data member not found"
0
 
LVL 75
ID: 24399599
That's cool Rocki.  I will have to remember that on.

mx
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24399664
cheers mx

In A2000? Hmm. not sure. I do not have A2000 but reading up on this, it looks like it is not available in that version.
0
 
LVL 1

Author Comment

by:PeterWhitts
ID: 24401560
OK Thanks anyway.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24401599
Possibly use PrvDevMode http://msdn.microsoft.com/en-us/library/aa207072(office.10).aspx
bit of expert vba coding required though Im afraid. I havent tried this before so dont know

Quick google check found this http://www.access-programmers.co.uk/forums/showthread.php?t=28384
Might help you. This does talk about a report, not a query though. Im not sure if a query object as that property
0
 
LVL 1

Author Comment

by:PeterWhitts
ID: 24402201
Thanks Rockie...an interesting puzzle.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

751 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