printing a record
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 w开发者_JS百科indow to select the printer, it is automatically sending to default printer.
Can anyone help to pop up print window to select printer from that.
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.
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!
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.
精彩评论