That's right. Subforms are not open in their own right, i.e. they are not
part of the Forms collection.
See:
Referring to Controls on a Subform
at:
http://allenbrowne.com/casu-04.html
for the general syntax, and the difference between a subform control and the
form in that control.
As far as your code goes, could you just pass the entire control and/or form
reference to your function?
Public Sub CompareStrings(frm As Form, ctl As Control)
Debug.Print frm.Name
Debug.Print ctl.Name, ctl.Value
...
You would then call it like this, regardless of whether you are in a main
form's or a subform's module:
Call CompareStrings(Me, Me.Text0)
Or, if you are in the main form's module and want to pass a reference to the
subform:
Call CompareStrings(Me.[Sub1].Form, Me.[Sub1].Form!Text0)
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Kan D." <kand1973@hotmail.com> wrote in message
news:%23nkNilRoGHA.2264@TK2MSFTNGP04.phx.gbl...
|