Hello,
I have a button on a form, designed to open a report. I have created a message to come up if the report has no records. The message does come up, but, when I close the message, I get an error related to the button's OnClick event: Macro error 2501, and the DoCmd OpenReport line is highlighted.
This is the code I have for Report's NoData event:
Private Sub Report_NoData(Cancel As Integer)
MsgBox "The requested waiting list has no names on it", vbOKOnly, "Error"
Cancel = True
End Sub
This is the code I have for the button on the form, designed to save and then open the report: (clicking this button brings up the "no records" message, but then the error when you close out the message.)
Private Sub butWaitingList_Click()
DoCmd.RunCommand acCmdSaveRecord
'Print Preview Waiting List
'using [RPTLimited-WaitingList]
DoCmd.OpenReport "RPTLimited-WaitingList", acViewPreview, , "RandCourseDetailsID = " & Me!RandCourseDetailsID
End Sub
The button seems to trigger the report's "No data message" but then still tries to open the report.
Any help would be great!
Thanks!