打印记录
我正在使用此代码从表单打印记录
Private Sub btnPrintRecord_Click()
On Error GoTo Err_btnPrintRecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
Exit_btnPrintRecord_Click:
Exit Sub
Err_btnPrintRecord_Click:
MsgBox Err.Description
Resume Exit_btnPrintRecord_Click
End Sub
但是,此代码不会弹出打印窗口来选择打印机,它会自动发送到默认打印机。
任何人都可以帮助弹出打印窗口以从中选择打印机。
I am using this code to print a record from the form
Private Sub btnPrintRecord_Click()
On Error GoTo Err_btnPrintRecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
Exit_btnPrintRecord_Click:
Exit Sub
Err_btnPrintRecord_Click:
MsgBox Err.Description
Resume Exit_btnPrintRecord_Click
End Sub
But, this code is not popping up print window to select the printer, it is automatically sending to default printer.
Can anyone help to pop up print window to select printer from that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
至少从 Access 2000 开始,DoMenuItem 已被弃用。您可以使用 RunCommand 打开打印窗口。
打印记录几乎从来都不是一个好主意。构建一个可以与Where 参数一起使用的报告并不需要很长时间。这将为您提供更多控制权,并为您的用户带来更愉快的体验。
DoMenuItem has been deprecated since at least Access 2000. You can use RunCommand to open the print window.
It is almost never a good idea to print a record. It does not take long to build a report which can be used with a Where argument. This will give you much more control and give your users a much more pleasant experience.
您是否研究过 Printer 对象(它是在 A2002 中引入的)?您可以使用它来获取有关打印机的信息并创建自己的对话框窗体以允许用户选择打印机,然后将其设置在打印机对象上并打印报告。我从未真正使用过它,所以无法给出详细说明,但这是处理此问题的正确方法。
是的,这可能比看起来需要的更难,但相信我,这比引入 Printer 对象之前要容易得多!
Have you looked into the Printer object (it was introduced in A2002)? You can use it to get information about the printers and create your own dialog form to allow the user to pick the printer, then set it on the Printer object and print your report. I've never really used it, so can't give detailed instructions, but that's the proper way to handle this.
And, yes, this is probably harder than it seems it needs to be, but believe me, it's a helluva lot easier than it was before the introduction of the Printer object!
如文档中所述,
DoCmd.PrintOut
不显示打印对话框。我想到的第一个解决方案是使用 SendKeys 函数,发送 Ctrl+P 并以这种方式打开打印对话框。
As stated in the documentation,
DoCmd.PrintOut
does not show the print dialog.The first solution that comes to my mind is to use the
SendKeys
-function, send Ctrl+P and open the print dialog that way.