Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Location
    United Kingdom
    Posts
    56

    Cool Unanswered: No Data Issue - REPORTS

    Hello,

    I have a button on a form that launches a report. This report is based on a query that asks the user to enter the invoice number. I have used the code below, but I want to get it to do the following:

    If the user enters a number and there is no data attached I do NOT want the report to print out (with 'error' all over it). I want it to cancel the event and display a message box stating that there is no data available. I have tried several things out but with no luck. Any ideas?

    Thanks,

    Rusty


    Private Sub btnPrintInvoiceRequest_Click()

    On Error GoTo Err_btnPrintInvoiceRequest_Click

    DoCmd.OpenReport "rptInvoice Request Form_patient events", acViewPreview, , ""

    Exit_btnPrintInvoiceRequest_Click:
    Exit Sub

    Err_btnPrintInvoiceRequest_Click:
    Resume Exit_btnPrintInvoiceRequest_Click

    End Sub

  2. #2
    Join Date
    Apr 2004
    Location
    ny, ny
    Posts
    224
    Private Sub Report_NoData(Cancel As Integer)
    MsgBox "The report has no data.", vbOKOnly + vbInformation
    Cancel = True
    End Sub

Posting Permissions

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