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

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

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