Results 1 to 6 of 6
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    Turn off message from access when "NoData" encountered


    I have a report with the "NoData" event coded:
    Code:
    Private Sub Report_NoData(Cancel As Integer)
    MsgBox "There are no names " & """Selected"""
    Cancel = True
    End Sub
    Simple enough eh? However, Access still issues the message:

    Click image for larger version. 

Name:	NoData.jpg 
Views:	8 
Size:	69.3 KB 
ID:	24195

    What do I do to get Access to stop issuing that message?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,815
    What you have should work, but the message is referring back to the method you used to open the report so the answer might lie in the DoCmd line you use to open the report. Can you post that?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Function "PrintSelNameTags" is the action specified in a right-click popup menu.

    Code:
    Private Function PrintSelNameTags()
    
    DoCmd.OpenReport "rptNameTags", acViewPreview
            
    End Function

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,815
    You have no error trap for this (error 2501) in either place. Mind you, I think that it won't work in the report open code anyway because execution goes back to the initiating code when the report is opened (or canceled), so I'm pretty sure I've always put the error trap for this issue there. Try this
    Code:
    Private Function PrintSelNameTags()
    On Error GoTo errHandler
    
    DoCmd.OpenReport "rptNameTags", acViewPreview
    
    errHandler:
    If Err.Number = 2501 Then 
      Exit Function
    Else
      msgbox "Error " & Err.Number & ": " & Err.Description
    End If
    End Function
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Your suggestion of adding error handler code to the function cleared up the offending informational message. Never occurred to me to tackle the issue from the point-of-view of an error condition. My mindset was locked in on the notion that it was a proper method I was somehow missing.

    Thanks,
    Bill

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,815
    Glad to have helped!

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

Similar Threads

  1. Replies: 4
    Last Post: 05-28-2015, 01:51 PM
  2. Suppress "Error" message following "Cancel = True"
    By GraeagleBill in forum Programming
    Replies: 7
    Last Post: 03-23-2014, 05:40 PM
  3. Replies: 22
    Last Post: 10-10-2013, 12:47 PM
  4. turn "about to delete record" warning back on
    By markjkubicki in forum Programming
    Replies: 1
    Last Post: 11-01-2012, 12:21 PM
  5. Replies: 3
    Last Post: 12-06-2010, 04:06 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