View Full Version : Report Printer Settings


lfva
05-02-2005, 03:12 AM
I'm running Access 2002, version 10.6501.6735, SP3. I want to change REPORT PRINTER SETTINGS from code.

Following code (as an example) is in a module and runs fine when executed e.g. from the immediate window: The DoCmd.Close statement prompts for the reports to be saved.

It however does NOT run ok when triggered from e.g. a button on a form : The DoCmd.Close statement does not prompt, and changes are NOT saved ... Who can help ?

Sub ChangeSettings()
Dim AnyRep as Report, AnyPrt as Printer
Set AnyPrt = Application.Printers(1)
AnyPrt.Orientation = acPRORLandscape
DoCmd.OpenReport "AnyReport",acViewDesign,,,acHidden
Set AnyRep = Reports("AnyReport")
AnyRep.Printer = AnyPrt
AnyRep.Printer.Orientation = acPRORLandscape
DoCmd.Close acReport, "AnyReport",acSavePrompt
End Sub

And in any form's code:

Sub AnyButton_Click()
ChangeSettings
End Sub

Thanks - Lieven