By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,847 Members | 2,285 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,847 IT Pros & Developers. It's quick & easy.

Code not completely running

P: n/a
I posted this about an hour ago, but I don't see it. I apologize if it
is doubled.

Hello all,

I have a form in Access XP that returns all printers intalled on the
user's system. They select which printer they want to print to and
click a "Next" button. The button click event runs the code posted at
the bottom of this message to open a number of reports, change the
printer to the one the user specified, save and close, then print the
reports. The code does everything but save the printer, so the report
prints to whatever printer was previously saved in the report.

This code runs fine if run directly within the module, but when it's
fired from a click event in a form it doesn't.

I have repaired and decompiled, any other thoughts? Thanks in advance
for any advice you may have.

code:

Public Sub sChangePrinter(strReport As String, strDeviceName As String,
Optional strOrientation, Optional strPaperSize)

Dim rpt As Report
DoCmd.OpenReport strReport, acViewPreview
Set rpt = Reports(strReport)
rpt.Printer = Application.Printers(strDeviceName)
rpt.Printer.Orientation = strOrientation
rpt.Printer.PaperSize = strPaperSize
DoCmd.Close acReport, strReport, acSaveYes
rpt.Printer = Application.Printers(strDeviceName)
rpt.Printer.Orientation = strOrientation
rpt.Printer.PaperSize = strPaperSize
DoCmd.Close acReport, strReport, acSaveYes
DoCmd.OpenReport strReport, acViewNormal

End Sub

Nov 13 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.