Results 1 to 7 of 7
  1. #1
    andy-29 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Culver City
    Posts
    34

    Run-time error '2501', The OpenReport action was canceled.


    I get error 2501 when I cancel the report.

    How do I go about this error?

    When cancel is clicked, can it just resume and maybe just open a form?
    Click image for larger version. 

Name:	cancel.JPG 
Views:	14 
Size:	28.5 KB 
ID:	10162

  2. #2
    andy-29 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Culver City
    Posts
    34
    This is what I have in there. I don't know VB much. Don't know how to create error handling

    Private Sub cmdPrintMarkerInfoForm_Click()
    DoCmd.Close
    DoCmd.OpenReport "Marker_Info_by_StyleID", acViewPreview
    End Sub

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You can add an error trap:

    http://www.baldyweb.com/ErrorTrap.htm

    and don't include a message box for that error.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    andy-29 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Culver City
    Posts
    34
    Is this correct??

    Private Sub cmdPrintMarkerInfoForm_Click()
    On Error GoTo ErrorHandler
    DoCmd.Close
    DoCmd.OpenReport "Marker_Info_by_StyleID", acViewPreview

    ExitHandler:
    Exit Sub
    ErrorHandler:
    Select Case Err
    Case 2501
    DoCmd.Hourglass False
    Resume ExitHandler
    Case Else
    MsgBox Err.Description
    DoCmd.Hourglass False
    Resume ExitHandler
    End Select

    End Sub

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    If it works, yes. If it doesn't, no.

    Offhand it looks okay.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    andy-29 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Culver City
    Posts
    34
    Tried it and it works, thanks!

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Excellent! Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Suppressed run time error 2501
    By RachelBedi in forum Programming
    Replies: 8
    Last Post: 10-24-2012, 12:26 PM
  2. Replies: 15
    Last Post: 07-26-2012, 02:06 PM
  3. Replies: 7
    Last Post: 07-18-2012, 07:53 AM
  4. Replies: 3
    Last Post: 05-06-2012, 06:29 PM
  5. Error: The OpenReport action was canceled
    By francisdm@state.gov in forum Reports
    Replies: 1
    Last Post: 12-14-2011, 01:45 PM

Tags for this Thread

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