List of of reports, captions and tags

Posted on 2011-05-04
Last Modified: 2012-06-27
I would like to display a list of reports in the database and display the report caption and also pick up the report tag (to filter items I don't want on list)

I would like to do this in a compiled ade.
I can loop through the reports collection and display the report name but I think I need to open the report to read the caption and tag.

Is there an easy way to do this - I could not get this to work for collection but even for an individual report opening the report started to trigger the on open events which I would prefer not to do as some require parameters.

Appreciate any ideas

Question by:donhannam
    LVL 12

    Expert Comment

    Check below link out, I guess that would help you to accomplish that;

    LVL 26

    Expert Comment

    You could open the reports to design view.
    That triggers no code!

    Proof of concept works

    Public Sub TagsAndCaptions()
    'On Error GoTo myerror
    Dim rpt As AccessObject
    For Each rpt In Application.CurrentProject.AllReports
        DoCmd.OpenReport rpt.Name, acViewDesign
        MsgBox Nz(Reports(rpt.Name).Caption, "No Caption") & " " & Nz(Reports(rpt.Name).Tag, "No tag") & " " & rpt.Name
        DoCmd.Close acReport, rpt.Name, acSaveNo
    Next rpt

    End Sub

    Adapt it to your needs instead of msgboxing

    Author Comment

    Thanks Nick67:

    I have tried this - works fine in an adp database but got an error trying to open a report in design view in an ade database.

    danishani: that web site seems to be down at the moment - I'll try later.

    Author Comment

    danishani: I had a look at this code - It does not work in an adp database - errors on all dim statements and I think even if I did get working it is just giving me the form name from the forms collection. i really need to get to the caption.
    LVL 26

    Accepted Solution

    Ok, two plans of attack.
    Since the ade won't change after deployment, can the stuff from my routine go into a table?
    Or you have no control over the back-end?
    I don't do ADO but

    set rs = currentdb.openrecordset("select * from tblReportdetails where 1=2;",dbopendynaset, dbseechanges)
    with rs
        !TheName =  rpt.Name
        !TheCaption = Nz(Reports(rpt.Name).Caption, "No Caption")
        !TheTag = Nz(Reports(rpt.Name).Tag, "No tag")
    end with

    shouldn't be that tough to set up ***If*** you can create a table.

    The other attack:
    Private Sub Report_Open(Cancel As Integer)
    if me.openargs = "to steal details" then
        me.recordsource = "select from a dummy table where 1=2"
    end if
    'Now, load the name, caption and tag someplace
    End Sub

    Now, by rights, the reports will have no data and should close.

    Catch my drift?


    Author Closing Comment

    Thanks Nick67:

    I have had a go at these and whilst they work will require a bit of ongoing admin.

    I decided it would be easier to set up a table in the database listing the reports and info I need so have gone with that option.
    LVL 26

    Expert Comment

    It should be easy enough to set up a routine that you run just before you finalize that whacks the contents of a table, and then appends using the code above.
    On my own stuff I have a button that runs such a routine.
    There's a PAQ about the use of returnusername and doing that kind of stuff here

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

    779 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

    15 Experts available now in Live!

    Get 1:1 Help Now