Insert this code behind the button you use to open the report (substituting in the appropriate names):
Private Sub cmdButtonName_Click()
On Error GoTo Err_cmdButtonName
DoCmd.OpenReport "rptName", acViewPreview
Exit_cmdButtonName:
Exit Sub
Err_cmdButtonName:
' This traps the error message
If Err = 2501 Then
Resume Exit_cmdButtonName
Else
MsgBox Err.Description
Resume Exit_cmdButtonName
End If
End Sub
Insert this code in the On NoData event procedure of the report:
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ErrorHandler
MsgBox "There are currently no records", vbOKOnly
Cancel = True
ExitReport:
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume ExitReport
End Sub
Linda Adams
Visit my web site for writing and Microsoft Word tips:
Official web site for actor David Hedison: