On Open Event Procedure Help For a Report

P

Playa

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
 
R

Rick Brandt

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top