Results 1 to 3 of 3
  1. #1
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727

    Run Time Error when Print is canceled


    I have a print button in the report header. Here is the simple code I have behind the button:

    Private Sub cmdPrint_Click()

    DoCmd.RunCommand acCmdPrint

    End Sub

    However, if I cancel the print I get this error:

    Run-time error '2501':
    The RunCommand action was canceled.

    Does anyone know how to get rid of this?

  2. #2
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407
    If nothing else happens, or it doesn't crash, you could try

    Private Sub cmdPrint_Click()
    On Error Resume Next
    DoCmd.RunCommand acCmdPrint
    End Sub

  3. #3
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Thanks that worked!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 15
    Last Post: 12-04-2012, 01:39 PM
  2. Replies: 6
    Last Post: 11-28-2012, 03:43 PM
  3. Replies: 15
    Last Post: 07-26-2012, 02:06 PM
  4. Replies: 7
    Last Post: 07-18-2012, 07:53 AM
  5. Error: The OpenReport action was canceled
    By francisdm@state.gov in forum Reports
    Replies: 1
    Last Post: 12-14-2011, 01:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums