Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Jun 2004
    Location
    Lambertville, New Jersey, USA
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Report NoData event (2002/2003)

    I would like to display a message and close the report if the query fails to generate any records. I'm using the NoData event but can't seem to close the report without generating an error.

    Can anybody help?

    Thanks,
    Lance

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Report NoData event (2002/2003)

    Do you open the report using DoCmd.OpenReport? If so, create an error handler and ignore error 2501 (the error that occurs when the report is canceled). For example:

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

    ErrHandler:
    If Err = 2501 ' report canceled
    ' don't do anything, just ignore the error
    Else
    ' display the error message
    MsgBox Err.Description, vbExclamation
    End Sub

  3. #3
    Star Lounger
    Join Date
    Jun 2004
    Location
    Lambertville, New Jersey, USA
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report NoData event (2002/2003)

    That's perfect.
    Thanks,
    lance

  4. #4
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Brisbane, Queensland, Australia
    Posts
    387
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Report NoData event (2002/2003)

    Thanks Hans This is exactly what I did - but I was trying to handle the 2501 error in the report not the code opening the report
    many thanks Hans

Posting Permissions

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