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
LVL 1
PeterWhittsAsked:
Who is Participating?
 
rockiroadsConnect With a Mentor Commented:
Howdo Peter, try setting the orientation on the printer

eg

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

0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
 
PeterWhittsAuthor Commented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
 
PeterWhittsAuthor Commented:
Cool answer...thanks RR
0
 
PeterWhittsAuthor Commented:
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
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
That's cool Rocki.  I will have to remember that on.

mx
0
 
rockiroadsCommented:
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
 
PeterWhittsAuthor Commented:
OK Thanks anyway.
0
 
rockiroadsCommented:
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
 
PeterWhittsAuthor Commented:
Thanks Rockie...an interesting puzzle.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.