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

    no data in report (acces 97-sr-2)

    I have a report that prints ok with data, but if there is no data I get a #error. I remember running code to get rid of the "#error" and have an invisible label appear stating there is no data to print.

    I can't remember what I did and can't find my old code. Can anyone help?
    Thanks,
    Mike

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: no data in report (acces 97-sr-2)

    Use the OnNoData Event. This code should get you started. The example shows how to cancel printing a report when it has no data. A message box notifying the user that printing has been canceled is displayed.

    <pre>Private Sub Report_NoData(Cancel As Integer)
    MsgBox "The report has no data." _
    & chr(13) & "Printing is canceled. " _
    & chr(13) & "Check the data source for the " _
    & chr(13) & "report. Make sure you entered " _
    & chr(13) & "the correct criteria (for " _
    & chr(13) & "example, a valid range of " _
    & chr(13) & "dates),." vbOKOnly + vbInformation
    Cancel = True
    End Sub
    </pre>

    HTH

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

    Re: no data in report (acces 97-sr-2)

    This is one of the few areas in which I use a macro. I have an EmptyReport macro that has 3 actions in it: display a message box, restore screen (I maximize it when report opens), then CancelEvent. Since I put this in every report I make, I find it easier to point to this macro in the OnNoData event, rather than cut and paste code.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

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

    Re: no data in report (acces 97-sr-2)

    Why not turn it into a function and call it the same way you do the macro?
    Charlotte

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

    Re: no data in report (acces 97-sr-2)

    You wrote:
    >>Why not turn it into a function and call it the same way you do the macro?<<

    This would be a viable alternative. I guess I first started using it before I knew that you could use the syntax =function() in the event property. I have a Macro called reports, that has several named macros in it (Empty Report, Maximize, Restore, etc.). When I hit the down arrow in the Event property, these macros display and it is easy to select one. Like I said, I don't have alot of macros (these are about it), so the list isn't too long.
    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
  •