The following Function should help you out:
'---------------------------------------------------------------------------------------
' Procedure : ListOpenRpts
' Author : CARDA Consultants Inc.
' Website :
http://www.cardaconsultants.com
' Purpose : Returns a list of all the loaded reports (preview or design)
' separated by ; (ie: Report1;Report2;Report3)
' Copyright : The following may be altered and reused as you wish so long as
the
' copyright notice is left unchanged (including Author, Website
and
' Copyright). It may not be sold/resold or reposted on other
sites.
'
' Revision History:
' Rev Date(yyyy/mm/dd) Description
'
**************************************************************************************
' 1 2009-Oct-30 Initial Release
'---------------------------------------------------------------------------------------
Function ListOpenRpts()
On Error GoTo Error_Handler
Dim DbO As AccessObject
Dim DbP As Object
Dim Rpts As Variant
Set DbP = Application.CurrentProject
For Each DbO In DbP.AllReports 'Loop all the reports
If DbO.IsLoaded = True Then 'Ensure the report if open
Rpts = Rpts & ";" & DbO.Name
End If
Next DbO
If Len(Rpts) > 0 Then
Rpts = Right(Rpts, Len(Rpts) - 1) 'Truncate initial ;
End If
ListOpenRpts = Rpts
Exit Function
Error_Handler:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & _
Err.Number & vbCrLf & "Error Source: ListOpenRpts" & vbCrLf & "Error
Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Exit Function
End Function
'---------------------------------------------------------------------------------------
' Procedure : CountOpenRpts
' Author : CARDA Consultants Inc.
' Website :
http://www.cardaconsultants.com
' Purpose : Returns a count of the number of loaded reports (preview or
design)
' Copyright : The following may be altered and reused as you wish so long as
the
' copyright notice is left unchanged (including Author, Website
and
' Copyright). It may not be sold/resold or reposted on other
sites.
'
' Revision History:
' Rev Date(yyyy/mm/dd) Description
'
**************************************************************************************
' 1 2009-Oct-30 Initial Release
'---------------------------------------------------------------------------------------
Function CountOpenRpts()
On Error GoTo Error_Handler
Dim DbO As AccessObject
Dim DbP As Object
Dim Rpts As Variant
Set DbP = Application.CurrentProject
CountOpenRpts = 0
For Each DbO In DbP.AllReports 'Loop all the reports
If DbO.IsLoaded = True Then 'Ensure the report if open
CountOpenRpts = CountOpenRpts + 1
End If
Next DbO
Exit Function
Error_Handler:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & _
Err.Number & vbCrLf & "Error Source: CountOpenRpts" & vbCrLf & "Error
Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Exit Function
End Function
--
Hope this helps,
Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples:
http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.