On Open Event Procedure Help For a Report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to display a message box if there are no records in a report when it
is opened. I am not really sure how to code this, here is the code I am
using but it doesn't work.

Private Sub Report_Open(Cancel As Integer)
If IsNull(Me.MachineNum) Then
MsgBox "There is no Revision History for this Machine Number"
End If
End Sub

Any one know how I can check to see if there are any records and if not,
display a message box?

Thanks in Advance
 
Playa said:
I want to display a message box if there are no records in a report when it
is opened. I am not really sure how to code this, here is the code I am
using but it doesn't work.

Private Sub Report_Open(Cancel As Integer)
If IsNull(Me.MachineNum) Then
MsgBox "There is no Revision History for this Machine Number"
End If
End Sub

Any one know how I can check to see if there are any records and if not,
display a message box?

Use the OnNoData event instead. Display your MsgBox and then set the
Cancel argument to True and the report will not open. This will be
interpreted as an Error number 2501 if the report was being opened from
code or a macro so you will need to trap and ignore that.
 
Back
Top