Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I abort a report with no data (Access03)

    How do I abort a report for displaying if there is no one to report on? The report is restrained between two dates and to a specific person's ID number. If the operator asks for the wrong person or someone without a grievance or disciplinary action the form should not open and a message displayed saying there is no data to be returned.

    How do I do that?

    Thank you! Fay

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How do I abort a report with no data (Access03)

    Use the NoData event of the report itself. You can put something like this in the NoData event in the report's code module:

    <pre>Private Sub Report_NoData(Cancel As Integer)
    MsgBox "There is no data for the criteria specified."
    Cancel = True
    End Sub</pre>


    If you call the report from a form, you'll need to put handling in the form's module to trap the 2501 error that will be triggered by the NoData cancellation as well.
    Charlotte

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How do I abort a report with no data (Access03)

    Thank you Charlotte. I haven't been there before. I always like to learn new tools. I will look up the 2501 error. Fay

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: How do I abort a report with no data (Access03)

    I use a slight alternative to Charlotte's suggestion. Rather than putting this in code, I have a macro that does the same thing (this is one of the few places I use macros). The macro shows up in the dropdown in the "Not In List" property box, plus it avoids creating a code module (if the report has no other code). You still have to trap that 2501 error if the report is run from a form. Use whichever method is easier for you, they both do the job.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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