C
Cynthia_adv
I do not understand why I have an error message on a NoData message based on
a report. I have a form which has a combo box to choose the parameter of a
report. Once you choose the parameter from the list, you click on OK and it
runs the report. If there is no data for the report, you get a message box
stating there are no records. Every time I run the report with no records, I
get the message box, but it also gives me an error.
The coding for the OK button is as follows:
Private Sub OK_btn_Click()
Me.Visible = False
DoCmd.OpenReport "Program Participation for Volunteers - by Program",
acViewPreview
DoCmd.close acForm, "Entry Form for Program Participation by Volunteers
Report"
End Sub
The coding for the NoData message for the report is as follows:
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ErrHandler
MsgBox "Sorry. There are no records" & vbCrLf & vbCrLf & "to display
or this report.", vbInformation + vbOKOnly, " No Records"
Cancel = True
Exit Sub
DoCmd.close acReport, "Program Participation for Volunteers - by Program"
DoCmd.close acForm, "Entry Form for Program Participation by Volunteers
Report"
ErrHandler:
MsgBox "Error in Report_NoData()" & vbCrLf & "in " & Me.Name & "
report." & vbCrLf & vbCrLf & Err.Number & vbCrLf & Err.Description
End Sub
If you run the report for a parameter with no records, you get a message box.
The heading says “No Recordsâ€
The message reads “Sorry, there are no records to display for this report.â€
and has an OK button.
If you click on the OK button you get another pop-up which says:
“Run-time error ‘2501’:
The OpenReport action was canceled.â€
And has End, Debug, and Help buttons.
If you click on the End button, the message box disappears.
If you click on the Debug button, you are brought to Visual Basic editor
under the OK_btn_Click() Private Sub with the 2nd line of code highlighted
yellow (DoCmd.OpenReport "Program Participation for Volunteers - by Program",
acViewPreview).
I don’t understand why this is happening. I cannot keep having this error
keep popping up, but would like to keep the NoData error message when you run
the report.
a report. I have a form which has a combo box to choose the parameter of a
report. Once you choose the parameter from the list, you click on OK and it
runs the report. If there is no data for the report, you get a message box
stating there are no records. Every time I run the report with no records, I
get the message box, but it also gives me an error.
The coding for the OK button is as follows:
Private Sub OK_btn_Click()
Me.Visible = False
DoCmd.OpenReport "Program Participation for Volunteers - by Program",
acViewPreview
DoCmd.close acForm, "Entry Form for Program Participation by Volunteers
Report"
End Sub
The coding for the NoData message for the report is as follows:
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ErrHandler
MsgBox "Sorry. There are no records" & vbCrLf & vbCrLf & "to display
or this report.", vbInformation + vbOKOnly, " No Records"
Cancel = True
Exit Sub
DoCmd.close acReport, "Program Participation for Volunteers - by Program"
DoCmd.close acForm, "Entry Form for Program Participation by Volunteers
Report"
ErrHandler:
MsgBox "Error in Report_NoData()" & vbCrLf & "in " & Me.Name & "
report." & vbCrLf & vbCrLf & Err.Number & vbCrLf & Err.Description
End Sub
If you run the report for a parameter with no records, you get a message box.
The heading says “No Recordsâ€
The message reads “Sorry, there are no records to display for this report.â€
and has an OK button.
If you click on the OK button you get another pop-up which says:
“Run-time error ‘2501’:
The OpenReport action was canceled.â€
And has End, Debug, and Help buttons.
If you click on the End button, the message box disappears.
If you click on the Debug button, you are brought to Visual Basic editor
under the OK_btn_Click() Private Sub with the 2nd line of code highlighted
yellow (DoCmd.OpenReport "Program Participation for Volunteers - by Program",
acViewPreview).
I don’t understand why this is happening. I cannot keep having this error
keep popping up, but would like to keep the NoData error message when you run
the report.