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

Posted on 2008-11-13
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 84

    Accepted Solution

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now