• Microsoft Access Messages (Access 97 SR2)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Microsoft Access Messages (Access 97 SR2)

    Author
    Topic
    #361587

    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??
    ThanksNewJersey

    Viewing 2 reply threads
    Author
    Replies
    • #547032

      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.

      • #547073

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

        • #547080

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

        • #547082

          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 –

    • #547126

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

      [indent]


      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


      [/indent]

      • #547212

        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.

    • #547142

      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.

    Viewing 2 reply threads
    Reply To: Microsoft Access Messages (Access 97 SR2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: