I have a button on a form that allows users to print it. As we have multiple printers and each user may have different printing needs, I coded the button to bring up the Print dialog box.
It works fine except when someone clicks Cancel in the dialog box. Access says that there is a Run-Time Error (2501).
Here is the code I am using:
Private Sub cmdPrint_Click()
MsgBox "This will print all records unless you select otherwise.", vbInformation
DoCmd.RunCommand acCmdPrint
'remove this line of code if you do not want print options
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
End Sub
Does anyone know how to fix this? Additionally, can they also bring up a print preview screen?
I would appreciate any advice you can give.
Thanks,
Ben
It works fine except when someone clicks Cancel in the dialog box. Access says that there is a Run-Time Error (2501).
Here is the code I am using:
Private Sub cmdPrint_Click()
MsgBox "This will print all records unless you select otherwise.", vbInformation
DoCmd.RunCommand acCmdPrint
'remove this line of code if you do not want print options
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
End Sub
Does anyone know how to fix this? Additionally, can they also bring up a print preview screen?
I would appreciate any advice you can give.
Thanks,
Ben