?
Solved

Loop through Forms collection and debug.print Forms Recordsource

Posted on 2004-08-17
5
Medium Priority
?
590 Views
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.

Rehards
0
Comment
Question by:Philbee
[X]
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
5 Comments
 
LVL 39

Accepted Solution

by:
stevbe earned 500 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
    Next

End Function

Steve
0
 
LVL 9

Expert Comment

by:ornicar
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
0
 

Author Comment

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

Expert Comment

by:stevbe
ID: 11820143
you may need to change AllForms to

CurrentProject.AllForms

you could also get this from the DOcumenter ...

Tools --> Analyze --> Documenter

Steve
0
 

Author Comment

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

Featured Post

Technology Partners: 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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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