Curtis Inderwiesche
Curtis Inderwiesche

Reputation: 4990

Make a Query in MS Access default to landscape when printed

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.

Upvotes: 1

Views: 3319

Answers (2)

Brettski
Brettski

Reputation: 20101

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

Upvotes: 0

ahockley
ahockley

Reputation: 3732

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.

Upvotes: 3

Related Questions