Link to home
Start Free TrialLog in
Avatar of PeterWhitts
PeterWhittsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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

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
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

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
Avatar of PeterWhitts

ASKER

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?
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

ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cool answer...thanks RR
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"
That's cool Rocki.  I will have to remember that on.

mx
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.
OK Thanks anyway.
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
Thanks Rockie...an interesting puzzle.