"luanhoxung " <lu********@yah oo.comwrote
i have met trouble with referring textbox
of subform in VBA
i know i can do as: forms!mainform. subform.textbox
but i want do it in shorter path.
any suggestion about using variable ?
If the VBA is in the module of the main form, you can use the "Me" notation
for currently-active form, as
Me!SubformContr olName.Form.Tex tBox
I would NOT expect the format you show to work, but that might depend on
what you mean by "subform", as there is no "Subform" object in Access --
there is a Subform Control, into which a Form may be embedded.
The correct form for VBA in a standard Module (not the Form's Module),
would, in fact, be
Forms!MainFormN ame!SubformCont rolName.Form!Te xtBox
If you have repeated references to the TextBox, you might use
Dim tb as TextBox
Set tb = Forms!FormName! SubformControlN ame.Form!TextBo xName
and then use the Object Variable tb to refer to the Text Box, if all you
want to do is shorten the references... you will have to make the design
tradeoff of whether it is, in fact, more efficient to do it that way.
Larry Linson
Microsoft Access MVP