Results 1 to 2 of 2
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Thanked 0 Times in 0 Posts

    On no data (2003)

    I have some code on the "on no data" event of a report that says the following:

    Private Sub Report_NoData(Cancel As Integer)
    MsgBox "There is no information for that selection", vbInformation
    Cancel = True
    End Sub

    Is there some code I can put in the above that gets rid of the pop up form that says "The open report action was cancelled". It comes after the Msg Box that tells them there is no information for that selection.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: On no data (2003)

    I assume that you open the report from a form using DoCmd.OpenReport. You can suppress the message by using an error handler like this:

    Private Sub cmdReport_Click()
    On Error GoTo ErrHandler
    DoCmd.OpenReport "rptSomething", acViewPreview
    Exit Sub

    If Err = 2501 Then
    ' This is the error that occurs if the report is canceled
    ' So we just ignore it
    ' Display other errors
    MsgBox Err.Description, vbExclamation
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts