PleaseGiveHelp
Programmer
I have created a MS Access report. When there is data to display, there is no problem. When there is NO data, I have included code (provided by someone here?) to display 'No records to display' and to prevent the report from being previewed. However, after the message box with the 'No records to display' message appears, I get another message: 'The OpenReport action was cancelled. You used a method of the DoCmd object to carry out an action in Visual Basic, but then clicked Cancel in a dialogue box. For example, you used the Close method to close a changed form, then clicked Cancel in the dialoge box that asks if you want to save the changes you made to the form.
The code behind the 'No records to display' is as such:
Private Sub Report_NoData(Cancel As Integer)
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
strMsg = "This group code produces no data"
intStyle = vbOKOnly
strTitle = "No data"
MsgBox strMsg, intStyle, strTitle
Cancel = True
End Sub
How can I prevent the error message from being displayed?
The code behind the 'No records to display' is as such:
Private Sub Report_NoData(Cancel As Integer)
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
strMsg = "This group code produces no data"
intStyle = vbOKOnly
strTitle = "No data"
MsgBox strMsg, intStyle, strTitle
Cancel = True
End Sub
How can I prevent the error message from being displayed?