Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, New South Wales, Australia
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    On No Data (Access 97/SR2)

    I am using this code to display a msg when there is no data to print on a report:

    Private Sub Report_NoData(Cancel As Integer)
    MsgBox "Sorry." & Chr(13) & Chr(10) & "There is no data matching the selected criteria.", , "Important Message."
    Cancel = True
    End Sub

    The msg works correctly except that after I choose cancel, Access displays the msg:

    "The OpenReport action was canceled.
    You used a method of the DoCmd object to carry out an action in Visual Basic, but then clicked Cancel in a dialog box. etc etc"

    What's going on here and how can I stop the second msg?

    Thanks, in advance
    Nick

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: On No Data (Access 97/SR2)

    In the button On click event that invoke the report, remove the line in the Err_Button_Click: part:
    MsgBox Err.Description
    Francois

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

    Re: On No Data (Access 97/SR2)

    It would be a better idea to add a test for Err = 2501 in the error handler and then simply ignore that error when it occurs. This is the most common way of handling that situation and it still leaves the error handling intact for true errors.
    Charlotte

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: On No Data (Access 97/SR2)

    Hi Charlotte

    Is it common pratice to hard code for error messages?

    What happens when A97 moves up to A2k, etc.?

    Is Billy Bob consistence with error codes?

    Thanks, John

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

    Re: On No Data (Access 97/SR2)

    It is common practice to code around errors like that one, which isn't really an error but a conflict of events. So far, later versions of Access don't have any problem understanding that error. By the time we get to one that doesn't understand it, you're going to have to rebuild the entire application anyhow to use .Net technology. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

Posting Permissions

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