Message box

  • Thread starter Thread starter Lori
  • Start date Start date
L

Lori

I am using Access 97. I have a form where a user enters a
policy_nbr to run a query pulling any notes associated
with that policy_nbr. How can I have a message box
display stating there are no matching policy_nbr for the
number entered. Right now - the report is displayed and
is just says "error".

I have a report that is run based on a query that takes a
number entered on a form. Where would I put the code for
the message box? What type of event procedure might it be?

Thanks!
 
Check out the On No Data property for the report. This can be used to close
the report if there are no data to be displayed. Note that this returns an
Error 2501 to the calling form ("action cancelled"), so you'd need to trap
for this error in your form's code after the DoCmd.OpenReport step.
 
Thanks for your response Ken. I don't know how to trap
for an error. Could you provide a code example? Thanks!
 
On Error Resume Next
DoCmd.OpenReport "ReportName"
If Err.Number <> 0 And Err.Number <> 2501 Then
MsgBox "Error has occured."
End If
 
Back
Top