Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Print Orientation of Query automatically 2

Status
Not open for further replies.

4321z

Programmer
Oct 21, 2003
45
0
0
GB
Hi,

I'm trying to print out a report automatically after a sequence has run and the code below works fine except the report really needs to print out in landscape and not portrait, the code below opens the query in preview mode, prints it and then closes preview mode and the display then reverts to the original form the code is on. I tried the PrtDev function but that doesn't seem to work for queries, any ideas? If your wondering why i don't just make a report of the query it's because it's a crosstab and the fields are constantly changing so a report is out of the question

Dim stDocName As String

stDocName = "Query1"
DoCmd.OpenQuery stDocName, acViewPreview, acEdit
DoCmd.PrintOut
DoCmd.Close
 
Try this:

Dim stDocName As String

stDocName = "Query1"
Application.Printer.Orientation = acPRORLandscape
DoCmd.OpenQuery stDocName, acViewPreview, acEdit
DoCmd.PrintOut
DoCmd.Close

I hope it helps!

Zionman4
 
thanks Zionman4, unfortuantly i'm getting 'Method or Data member not found' run time error, do you know what libary i should reference for this method?
 
Use DAO. I tried it and it worked fine for me.

Good luck!
 
I think Application.Printer did not appear until Access XP.

What version are you using?
 
I'm using Access XP. I'm not sure how to do this any other way...Sorry.
 
Thanks for advice zionman4 and payback, i gave up with printing the query directly and found a useful bit of code for defining text boxes on a report at runtime and hiding the ones not used, so i can print the report in landscape no problem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top