Results 1 to 3 of 3
  1. #1
    Grant Shea is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    30

    Error Handling

    I have a number of buttons that open reports based on parameter values entered by the user. If the user clicks on cancel in the parameter value dialog box, I get Run-time error '2501' The OpenReport Action was cancelled.



    In order to not have this dialog box appear added an OnError Resume Next line. Is there a better way to do this?

    Code:
     Private Sub VocabButton_Click()
    On Error Resume Next
    DoCmd.OpenReport "Vocab Questions", acViewReport
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    no, that is the best.
    additional error handling code is for more complex stuff. What you have is fine.

  3. #3
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,463
    Can't you just check that value and if cancel is selected, skip the process?

    If me.ChoiceField <> "Cancel" then
    DoCmd.OpenReport "Vocab Questions", acViewReport
    End If

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

Similar Threads

  1. Replies: 5
    Last Post: 09-06-2015, 12:06 PM
  2. Error handling of table update error?
    By panoss in forum Forms
    Replies: 5
    Last Post: 10-31-2014, 02:06 PM
  3. Error Handling Question - On Error Goto
    By redbull in forum Programming
    Replies: 7
    Last Post: 12-06-2012, 07:54 AM
  4. Replies: 3
    Last Post: 09-05-2012, 10:23 AM
  5. Error 2501 displays with Error handling
    By agent- in forum Programming
    Replies: 13
    Last Post: 08-05-2011, 02:20 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