Simple Forms Collection Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm tying to get a handle on the forms collection. If I have 5 forms in my
application, why don't I get a message box for each of the forms in my
application using the code below? Currently, I'm only gettng the name of the
form where this handler exists and none of the other forms in the application.

Private Sub Detail_Click()

Dim Objform As Form
For Each Objform In Application.Forms
MsgBox (ObjForm.Name)
Next

End Sub


Thanks!
Bernie
 
bernadou said:
I'm tying to get a handle on the forms collection. If I have 5 forms
in my application, why don't I get a message box for each of the
forms in my application using the code below? Currently, I'm only
gettng the name of the form where this handler exists and none of the
other forms in the application.

Private Sub Detail_Click()

Dim Objform As Form
For Each Objform In Application.Forms
MsgBox (ObjForm.Name)
Next

End Sub

The Forms collection only includes "open" forms. Similar is true of the Reports
collection.
 
Ok, that helps a bunch, but, is there a way to iterate through all the forms
in an application without them being open?

Thanks
B
 
bernadou said:
Ok, that helps a bunch, but, is there a way to iterate through all
the forms in an application without them being open?

CurrentDB.Containers("Forms").Documents(n).Name

Will return the form name of each form if n is substituted with a value from
zero to the number of forms minus 1, but you cannot use that to get at all the
same properties that the Forms collection does.
 
Back
Top