At what point is a Form added to the Forms collection or a Report added
to the Report collection? I.e., listed as currently open. The reason
I ask is that I have a subreport for an exclusive separate condition
that may or may not have data. When it does have data its total needs
to be added to the final report total. I used a function like:
Public Function SubreportHasData(strReport As String, strSubReport As
String) As Boolean
Dim rptX As Report
SubreportHasData = False
For Each rptX In Reports
If rptX.Name = strReport Then
SubreportHasData =
Reports(strReport).Controls(strSubReport).Report.H asData
Exit For
End If
Next rptX
End Function
along with a totals ControlSource like:
=Format(Sum([QuotedJobTotal])+IIf(SubreportHasData("rptWorkInProgress","Subrep ortWorkInProgress"),Nz([txtTotSubQuotedJobTotal].[Value],0),0),"$#,##0.00")
which seemed to work. It also worked using
Reports("rptWorkInProgress").[Controls]("SubreportWorkInProgress").[Report].[HasData]
directly without a function call. This made me wonder about at what
precise point does it become safe to assume a Form or Report is in the
Forms or Reports collection.
Thanks,
James A. Fortune