When you choose CANCEL, Access generates Error 2501.
You need to trap this error and deal with it.
This code allows the user to return to the lstboxReports form
when the user clicks CANCEL. This is better than letting the user
get to the DEBUG Dialog box.
Private Sub lstbxReports_Click()
On Error GoTo err_NoData
DoCmd.OpenReport Me![lstbxReports], acViewPreview
exit_err_NoData:
Exit Sub
err_NoData:
If Err.Number = 2501 Then
Resume exit_err_NoData
Else
MsgBox Err.Description
Resume exit_err_NoData
End If
End Sub