No data on a report

Stacey

Registered User.
Local time
Today, 10:43
Joined
Sep 10, 2002
Messages
84
I have a macro set up to display a msg box when there is no data on a report accessed from a command button on a form. The macro is msg box, then CancelEvent. However, after the message box displays, a box pops up that says "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 dialog box......etc." I have searched Help for a way to stop that box from popping up, but I cannot find anything. What am I doing wrong?

Thanks
Stacey
 
i just use visual basic.
put this in the open of the report

Private Sub Report_Open(Cancel As Integer)

If DCount("*", Me.RecordSource) = 0 Then
MsgBox "No Data for this report", 16, "Sorry"
Cancel = True
End If

End Sub




also i use
on error resume next in the click of the button to open the report.
eg.

Private Sub Command9_Click()
On Error Resume Next
DoCmd.OpenReport "CBIT", acViewPreview
End Sub


Hope this helps you
Steve
 
Thank You!
 

Users who are viewing this thread

Back
Top Bottom