打印记录

发布于 2024-09-11 18:35:58 字数 432 浏览 4 评论 0原文

我正在使用此代码从表单打印记录

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧人九事 2024-09-18 18:35:58

至少从 Access 2000 开始,DoMenuItem 已被弃用。您可以使用 RunCommand 打开打印窗口。

DoCmd.RunCommand acCmdPrint

打印记录几乎从来都不是一个好主意。构建一个可以与Where 参数一起使用的报告并不需要很长时间。这将为您提供更多控制权,并为您的用户带来更愉快的体验。

DoMenuItem has been deprecated since at least Access 2000. You can use RunCommand to open the print window.

DoCmd.RunCommand acCmdPrint

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.

这样的小城市 2024-09-18 18:35:58

您是否研究过 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!

前事休说 2024-09-18 18:35:58

如文档中所述,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文