Results 1 to 4 of 4
  1. #1
    Jojojo is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    46

    How to Ignore Err 2501

    Hi!

    When a report is run and there are no records, I have a msg box that pops up to advise the user, instead of seeing #Errors on the report.

    But in some cases, I am still getting the erro 2501 message.

    This is the code I used to try and ignore it (based on searching the problem on various forums), but the err 2501 message still pops up. Can someone tell me how to correct this code?

    Private Sub Report_NoData(Cancel As Integer)
    On Error GoTo MyError
    MsgBox "There are no expenses entered for those dates.", vbInformation, "No Data"
    Cancel = True

    MyExit:
    Exit Sub

    MyError:
    If Err.Number = 2501 Then GoTo MyExit


    MsgBox Err.Description
    GoTo MyExit
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Here are the basics:

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

    Your code looks okay, but I think you have to trap for the error in the code that opens the report.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    May 2010
    Posts
    339

  4. #4
    Jojojo is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    46
    Quote Originally Posted by Access_Blaster View Post
    That worked perfectly! Thanks!

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

Similar Threads

  1. Replies: 15
    Last Post: 07-26-2012, 02:06 PM
  2. ignore delete error
    By smahdih in forum Access
    Replies: 1
    Last Post: 11-05-2011, 03:42 PM
  3. Replies: 9
    Last Post: 04-04-2011, 11:13 AM
  4. Ignore last two digits in formula
    By anstasija in forum Access
    Replies: 6
    Last Post: 11-02-2010, 08:57 PM
  5. On Click - Ignore Required Fields
    By amy in forum Forms
    Replies: 1
    Last Post: 08-18-2009, 07:42 AM

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