No Data Issue

Rusty

Registered User.
Local time
Today, 15:38
Joined
Apr 15, 2004
Messages
207
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
:D


Code:
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
 
Use the NoData event of the Report to display your message and cancel the request.
examples have been posted on the forum
 
Cheers Rich. I never thought of doing it that way...talk about the answer being right under your nose (and a lot simpler than I thought it would be).

Rusty
 

Users who are viewing this thread

Back
Top Bottom