enderland
enderland

Reputation: 14135

MS Access VBA not recognizing forms in Application.Forms until they are opened

If I run the following code:

  For i = 0 To Application.Forms.Count - 1
        Debug.Print Application.Forms(i).Name
  Next i

I am getting very strange results. The above code only recognizes forms I have opened or directly accessed (such as using ?mFormName.name in the intermediate window).

Access does not seem to see the other form objects or include them as part of Application.Forms. This also includes referencing them by name, such as Application.Forms("mFormName") - this does not work either.

I have some methods which run by iterating through a variety of forms and I would like to avoid having to open them all in order for the Access VBE to recognize them in this fashion.

Upvotes: 0

Views: 1749

Answers (1)

Gord Thompson
Gord Thompson

Reputation: 123399

Yes, the Application.Forms collection includes only opened forms. To iterate through all forms you can use the Application.CurrentProject.AllForms collection.

Upvotes: 3

Related Questions