Loop through Forms collection and debug.print Forms Recordsource

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
PhilbeeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
stevbeConnect With a Mentor Commented:
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
 
ornicarCommented:
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
 
PhilbeeAuthor Commented:
Thanks for that.  Almost got it myself.
0
 
stevbeCommented:
you may need to change AllForms to

CurrentProject.AllForms

you could also get this from the DOcumenter ...

Tools --> Analyze --> Documenter

Steve
0
 
PhilbeeAuthor Commented:
Cheers, made the adjustments myself.  Thanks again
0
All Courses

From novice to tech pro — start learning today.