Retrieve the Description property for All the MS Access Reports using VBA Code

Is it possible to loop through all the reports in the current database and retrieve the description for each report.  This is what I have so far:

Private Sub Command0_Click()
Dim obj As AccessObject, dbs As Object
Dim rpt As Report
Dim P As Property
Set dbs = Application.CurrentProject
For Each obj In dbs.AllReports
    Debug.Print obj.Property & vbCrLf
Next
End Sub


Any help would be appreciated.
yazbekAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You must get a handle on the Document for that object ... the code below does this for you. Copy/paste it into a Standard Module, then call it like this:

Dim sReportDescription As String

sReportDescription = GetDescription("YourReportName",acReport)

To use this in a Loop, just replace your Debug.Print with this:

GetDescription(obj.Name, acReport)



Function GetDescription(ObjectName As String, ObjectType As AcObjectType) As String
'/Purpose:
'/Created: 11/13/2008 07:13 AM
'/Created By: Scott
 
Dim doc As DAO.Document
Dim dbs As DAO.Database
Dim con As DAO.Container
 
On Error GoTo Err_GetDescription
 
Set dbs = CurrentDb
Set con = dbs.Containers(ObjectType)
Set doc = con.Documents(ObjectName)
 
GetDescription = doc.Properties("Description").Value
 
Exit_GetDescription:
  On Error Resume Next
  Set doc = Nothing
  Set dbs = Nothing
  Set con = Nothing
  Exit Function
 
Err_GetDescription:
 
  Select Case Err
    Case 3270 '/property not found
      GetDescription = ""
    'case
    Case Else
     MsgBox "An error occurred in this application." & vbCrLf & vbCrLf & Err & ":" & Error$ & vbCrLf & vbCrLf & "Technical Information: Occurred in [Module1].[GetDescription]", vbCritical, "Application Error"
  End Select
  
  
  Resume Exit_GetDescription
End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.