"Larry Linson" <bo*****@localhost.not> wrote in
news:HEe8g.20078$W83.7509@trnddc07:
A Form embedded in a Subform Control, even if visible is not "Open"
and, thus, not in the Forms Collection.
I believe it is open but I don't know if it's in the forms collection.
Try this.
1. Put some code in the subform's module or in recent Access versions set
the subform's HasModule property to true.
2. Put a textbox on the subform. Set it's default value to "Larry".
3. Open the main form. Move to the subform. Overwrite Larry with "Lyle"
in the textbox.
4. Leave the main form open.
5. Somewhere, anywhere in the application run this line.
MsgBox Form_subformName.textboxName.Value
ie if the subform's (not the control's) name is OrderItems and the
TextBox's name is Contact then
MsgBox Form_OrderItems.Contact.Value
The subform is definitely open now. If the message box says "Larry" then
clearly it just now opened and returns the default value. If it says
"Lyle" then it was open when you typed in "Lyle (prior to your call to
MsgBox).
Look in your VB editor. Make the Project Explorer visible. You will see
Form_OrderItems in Access Class Objects there. You can refer to
Form_OrderItems anywhere, anytime. It points to the default instance of
the form. If the form isn't open, it opens it (invisible unless its
visiblity is expressly set in its open event code). But if is open it
just points to that instance. And that's what happens here in Canada when
the form is being used as a subform.
As an aside, this gives us a simple way of creating multiple instances of
a form.
Dim SomeOrderItemForms(8) as Form_OrderItems gives us an array of 8
unitialized OrderItems forms. We can scan through our array, intialize
each form and give its properties unique values, suvh as Captions, Item
Orders (0), Item Orders (1), Item Orders(2) etc.
--
Lyle Fairfield