Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-05-15
11
Medium Priority
?
2,480 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
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!

 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

661 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