Loop through Forms collection and debug.print Forms Recordsource

Posted on 2004-08-17
Last Modified: 2012-06-27
I need to ba able to run some code that loops through all the form objects I have in my Access 2000 database, and pull out the name of the recordsource used by that form.  Any help much appreciated.

Question by:Philbee
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 39

Accepted Solution

stevbe earned 125 total points
ID: 11820051
what version of Access do you have?

Public Function DebugRS()
    Dim frm As AccessObject
    For Each frm In AllForms
        DoCmd.OpenForm frm.Name, acDesign
        Debug.Print Forms(frm.Name).RecordSource
        DoCmd.Close acForm, frm.Name, acSaveNo

End Function


Expert Comment

ID: 11820092
This one is the same, but works with versions before 2000:

Public Sub ListFormSources()
Dim frm As Form
Dim db As Database
Dim i As Integer
Dim FormName As String

Set db = CurrentDb()
For i = 0 To db.Containers("Forms").Documents.count - 1
    FormName = db.Containers("Forms").Documents(i).Name
    DoCmd.OpenForm FormName, acDesign
    Set frm = Forms(FormName)
    Debug.Print frm.Name & " RecordSource = " & frm.RecordSource
    DoCmd.Close acForm, FormName
Next i

End Sub

Author Comment

ID: 11820093
Thanks for that.  Almost got it myself.
LVL 39

Expert Comment

ID: 11820143
you may need to change AllForms to


you could also get this from the DOcumenter ...

Tools --> Analyze --> Documenter


Author Comment

ID: 11820158
Cheers, made the adjustments myself.  Thanks again

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 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