Hello,
I searched this forum and Google looking for a way to do this, but everyone's situation I found was unique enough for it not to work for me.
I have forms that will need to be printed by the user at times. I have used VBA code behind a "Print" button on the form. Here is my code:
It works fine unless:
1) User clicks the "Cancel" button on the print window if they change their mind...they then get "Run-time error '2501': The RunCommand action was canceled" with options to End, Debug, or go to Help. I don't want the users to get this confusing error, so I'd like to "handle" error 2501 so the user doesn't see this...maybe instead a message box that says "You have cancelled this print job" and only an "OK" button.
2) If the user clicks "Setup" on the print window, they get "This action can't be carried otu while processing a form or report event. A macro specified as the OnOpen, OnLoad, OnClose, OnFormat, OnRetreat, OnPage, or OnPrint property setting contains an invalid action for the property. When you click OK, an Action Failed dialog box will display the name of the macro that failed and its arguments." (No Action Failed dialog box comes up.)
Any help would be much appreciated! Thank you!
I searched this forum and Google looking for a way to do this, but everyone's situation I found was unique enough for it not to work for me.
I have forms that will need to be printed by the user at times. I have used VBA code behind a "Print" button on the form. Here is my code:
Code:
Private Sub cmdPrintMapArea1_Click()
DoCmd.RunCommand acCmdPrint
End Sub
It works fine unless:
1) User clicks the "Cancel" button on the print window if they change their mind...they then get "Run-time error '2501': The RunCommand action was canceled" with options to End, Debug, or go to Help. I don't want the users to get this confusing error, so I'd like to "handle" error 2501 so the user doesn't see this...maybe instead a message box that says "You have cancelled this print job" and only an "OK" button.
2) If the user clicks "Setup" on the print window, they get "This action can't be carried otu while processing a form or report event. A macro specified as the OnOpen, OnLoad, OnClose, OnFormat, OnRetreat, OnPage, or OnPrint property setting contains an invalid action for the property. When you click OK, an Action Failed dialog box will display the name of the macro that failed and its arguments." (No Action Failed dialog box comes up.)
Any help would be much appreciated! Thank you!