سؤال

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.

  • How can I iterate through my Access forms without manually opening/referencing them first? Application.Forms seems really buggy.
هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top