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

Posted on 2008-11-13
Medium Priority
Last Modified: 2013-11-27
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
End Sub

Any help would be appreciated.
Question by:yazbek
1 Comment
LVL 85

Accepted Solution

Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 22948934
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
'/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
  On Error Resume Next
  Set doc = Nothing
  Set dbs = Nothing
  Set con = Nothing
  Exit Function
  Select Case Err
    Case 3270 '/property not found
      GetDescription = ""
    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


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question