"DMUM via AccessMonster.com" wrote
Thank you very much for responding. Unfortuneatly
I got lost in your example. Can you describe a different way?
Well, first, let's get some terminology straight. There is no object in
Access called a "Subform", but there is an object called a "Subform
Control". Sometimes we say "subform" but we shouldn't as it is quite
obviously confusing.
A "Subform Control" has a "Source Object" which is a Form... that Form,
unless you have done some tricks with code, can also be opened directly, as
well as being the "Source Object" (aka "embedded in") the Subform Control.
{I hope this doesn't muddy the waters, but you can also use Datasheet View
in a Subform Control, but I strongly advise against Datasheet View either
alone or in a Subform, because there are too many things that an unwary user
can do that will be harmful.}
I am curious. you say the subform is not open? Really?
Yes, really.
I thought if the main form was open, the subform
was also open.
Back to the definition... no such thing as a Subform... only Subform
Controls, into which you embed a Form as Source Object. Controls aren't Open
or Closed... they have different Properties. Thus, not as you thought, that
instance of the Form exists as the Form property of the Subform Control.
if I try DoCmd.Open "subform" the subform will open
by itself. (Not within the Mainform)
Not germane to the discussion. It is a Form, not a Subform, and can be
Opened. When it is Opened directly, it is open and will be in the Forms
collection.
The form embedded in the subform control would be
my ? I'm lost with this.
It wouldn't be _your_ anything, it would be the SourceObject of the Subform
Control, and would be addressed as the Form property of the Subform Control.
I don't have a subform in my subform?
No, firstly, you don't have "a Subform," so you couldn't have anything in
it. Back to the clarification of terminology.
Let me see:
F2 is the main form
No, "F2" is the Form that is Source Object of the Subform Control, aka the
Form embedded in the Subform Control.
SF is my subform
No, SF is the Subform _Control_ which resides on the main Form F1. There's a
difference between the Subform Control and the Form that is its Source
Object -- they are different Access objects, have different Properties, and
serve different functions.
C are my controls on my subform SF
No, C represents a Control on Form F2, which is the Source Object of the
Subform Control SF, which is a Control on Form F1, which is the main Form.
What is F1?
F1 is the main Form.
Draw a big box on a sheet of paper to represent F1, the main Form. Inside
that box, draw a smaller box to represent SF, the Subform Control. Inside
the SF box, you can draw a picture of whatever's on Form F2, which is the
SourceObject of SF (aka the Form embedded in SF), and what you'll have drawn
are representations of the Controls C that reside on Form F2.
Also, how am I passing the name of the subform to my sub? if sub name is
unlock would it be
I wouldn't pass the "Name", but a Form object. And that would be, if your
code is in the main Form F1's module:
Dim frmPassMe as Form
Set frmPassMe = Me.SF.Form
Unlock (frmPassMe)
unlock( Forms!F1!SF.Form!C)
what would my sub look like
sub unlock(??????)
end sub
Sub Unlock (pfrmForm as Form)
do whatever you are going to do
to address a Control by text name, use something like
pfrmForm("NameOfControl").Locked = False
End Sub
If you do not have the same Controls on each of the Forms used as Source
Objects in Subform Controls, then, instead of passing the Form object, you
will need to pass the Control Object (unless you are going to use code to
open all the Controls of particular types in that Form's Controls
Collection).
Sorry I'm not getting it and requesting more explanation.
Sorry, I wasn't clear. Hope this is clearer. If not, post back, and either I
or someone else will take a shot at additonal clarification.
Larry Linson
Microsoft Access MVP