Simple Forms Collection Question

B

bernadou

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
 
R

Rick Brandt

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.
 
B

bernadou

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
 
R

Rick Brandt

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top