[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

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
0
Philbee
Asked:
Philbee
  • 2
  • 2
1 Solution
 
stevbeCommented:
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now