Solved

Loop through Forms collection and debug.print Forms Recordsource

Posted on 2004-08-17
5
544 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
  • 2
  • 2
5 Comments
 
LVL 39

Accepted Solution

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Display multiple images in report 12 84
Correct ordering 15 43
Another multiple criteria puzzle 4 18
Error in SQL Query 36 33
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

705 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

18 Experts available now in Live!

Get 1:1 Help Now