Solved

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

Posted on 2009-05-15
11
2,101 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
  • 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

706 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

20 Experts available now in Live!

Get 1:1 Help Now