One alternative would be to use a module level variable in the report to
track whether the report has records. When a report has no records, the
NoData event is fired. You can set the module level variable to true in the
NoData event, and then read its value in the Form Close event. For example:
Option Compare Database
Option Explicit
Dim m_NoData As Boolean
Private Sub Report_Close()
If m_NoData Then
Debug.Print "Form Close No Data"
Else
Debug.Print "Form Close With Data"
End If
End Sub
Private Sub Report_NoData(Cancel As Integer)
Debug.Print "No Data"
m_NoData = True
Cancel = True
End Sub
One potential drawback to this approach is that if the report were to
encounter an unhandled error (in most cases, unlikely), the module level
variable would be reset.
--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
I'm afraid I wasn't very clear on my previous post, my bad. What I want to
do is; if the
report has no records, I want to something and if the report has record(s) I
want to do something else OnClose.