Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NoData Event and Docmd.OpenReport Problem 1

Status
Not open for further replies.

Sydney1

Technical User
Jul 14, 2004
156
US
Hi,

I'm using the NoData event
Code:
On Error GoTo Err_Report_NoData
MsgBox "There is no data for this report. Canceling report..."
    Cancel = -1

Exit_Report_NoData:
    Exit Sub
 
Err_Report_NoData:
    MsgBox Err.Description
    Resume Exit_Report_NoData
in my reports, which is working fine. But I'm opening the reports from a form that is using
Code:
  DoCmd.OpenReport cboReportName.Column(2), acViewPreview
After I get my message that there is No data and the report is canceling I then get the "OpenReport Action was cancelled". error. "You used the method of the Docmd object to carry out an action in VB and then clicked the cancel in the dialog box"

Is there any code, with the corresponding error # that I can put in the error handling of the button that opens the report that would bypass this message?

Thanks for your help

Sydney
 
Brute force method:
On Error Resume Next
DoCmd.OpenReport cboReportName.Column(2), acViewPreview
If Err.Number <> 0
' your own specific error handling here
Err.Clear
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi,

Thanks again for your help. I put in your code in here
Code:
 With cboReportName
    For Each selStr In .ItemsSelected
        Select Case .Column(0, selStr)
  Case "19", "9"
        If IsNull(txtBeginDate) Or IsNull(txtEndDate) Then
                    MsgBox Trim(.Column(1, selStr)) & " requires Begin date and End date to be selected"
                    Exit For
                Else
On Error Resume Next
DoCmd.OpenReport cboReportName.Column(2), acViewPreview
If Err.Number <> 0 Then
  Err.Clear
End If

End If
and it appears to be working fine. have a question. I also have error handling on the whole procedure. Does On Error Resume Next only affect what happens in the If then statement that I put it in and not the whole procedure.

Thanks

Sydney
 
On Error Resume Next
DoCmd.OpenReport cboReportName.Column(2), acViewPreview
If Err.Number <> 0 Then
Err.Clear
End If
On Error GoTo PreviousErrorHandler

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Its working fine. Thanks again for your help.

Sydney
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top