Solved

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

Posted on 2009-05-15
11
2,225 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

821 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