views:

785

answers:

2

How can I programmatically make a query in MS Access default to landscape when printed, specifically when viewing it as a PivotChart? I'm currently attempting this in MS Access 2003, but would like to see a solution for any version.

+3  A: 

The following function should do the trick:

Function SetLandscape()
   Application.Printer.Orientation = acPRORLandscape
End Function

Should be able to call this from the autoexec function to ensure it always runs.

ahockley
A: 

Yes ahockley's call sets the application's printer orientation to landscape. I tried an experiment and it worked well. I know this doesn't produce a pivot table, but I didn't setup one to use, so it opens and prints a regular query.

Private sub
    Application.Printer.Orientation = acPRORLandscape
    DoCmd.OpenQuery "qry1", acViewNormal, acReadOnly
    DoCmd.PrintOut acPrintAll
End Sub

If you want to close the query after printing it, add:

docmd.Close acQuery, "qry1", acSaveNo
Brettski