Results 1 to 8 of 8
  1. #1
    Lounger
    Join Date
    Feb 2001
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Microsoft Access Messages (Access 97 SR2)

    I am using VB code to print reports from a main menu. The problems is whenever I do not complete the printing of a report, such as On No Data, I get a Microsoft Message that says the OpenReport Action was canceled. I do not want this message to show. My users are just going to get confused. How to I disable this??
    Thanks<img src=/S/flags/NewJersey.gif border=0 alt=NewJersey width=30 height=18>

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

    Re: Microsoft Access Messages (Access 97 SR2)

    Try using the SetWarnings action in VB, as in:
    DoCmd.SetWarnings False
    at the beginning of the module and
    'DoCmd.SetWarnings True
    at the end of the module.
    This will turn the warnings off before your report code executes and back on afterwards.

  3. #3
    Lounger
    Join Date
    Feb 2001
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Microsoft Access Messages (Access 97 SR2)

    I tried it but it did not work. When I do this same thing with a Macro I have not problems.

  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Microsoft Access Messages (Access 97 SR2)

    Have you tried converting the macro to code with the wizard?

  5. #5
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Microsoft Access Messages (Access 97 SR2)

    This is a bit of VBA code that we put on all our reports. Then no matter what you use (VBA, macro, standalone), you'll get a little message if there isn't any data. If you need to build this into VBA, let me know and I'll try to explain how to do that.


    Private Sub Report_NoData(Cancel As Integer)
    ' Display a message if there are no records for the report,
    ' and don't preview or print report.


    MsgBox "There is no data for this report.", , "No report Data"
    Cancel = True

    End Sub

    Hope this helps -
    Carpy Diem, it&#39;s .

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Microsoft Access Messages (Access 97 SR2)

    Easiest way to fix that is to check for error number 2501 in your error handling code. e.g.

    <hr>On Error GoTo Err_Do_Report_Click
    ...
    Err_Do_Report_Click:
    If Err.Number <> 2501 Then
    MsgBox Err.Number & " " & Err.Description
    End If
    Resume Exit_Do_Report_Click<hr>

  7. #7
    Lounger
    Join Date
    Jan 2001
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Microsoft Access Messages (Access 97 SR2)

    I was frustrated the same way. What I finally found the problem to be was the form that was calling the report neded the error handling. And rather than display any message as a result of this error, I chose to simply Resume processing. The code snipet below would be on the form's button...

    Private Sub cmdReport_Click()
    On Error GoTo Err_cmdReport_Click

    (do what ever here...)

    Err_cmdReport_Click:

    Resume Exit_cmdReport_Click
    End Sub


    I always provide a simple message to the user when no data are available. But I do it in the On No Data event of the form...

    Private Sub Report_NoData(Cancel As Integer)
    MsgBox "There is no data to print in this report.@ Please change your settings and try again.@Printing will be cancelled.", , "No Data to Display..."
    Cancel = True
    End Sub

    Hope this helps!

    Regards,

    Rich P.

  8. #8
    Lounger
    Join Date
    Feb 2001
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Microsoft Access Messages (Access 97 SR2)

    Thanks, I finally got it worked out. I used your code and everything worked fine. Again thanks, this was driving me crazy. I never thought of the error handling in the form.

Posting Permissions

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