Link to home
Start Free TrialLog in
Avatar of skennedy10
skennedy10Flag for United States of America

asked on

Refer to a subform's control's properties using a variable for the subform name.

I have about 11 subforms on tabbed pages on a single form.  I am trying to set them all with the exact same properties to eliminate the jumping--and need this type of coding for other things, too.  

I wish to have a module which will control the size properties and the location of several "special textboxes."  

I have variables for the actual subform names, strPageAfrm, strPageBfrm, etc. assigned as public constants since I will be duplicating this database many times with slightly different names.  I want to change things once instead of 12 or multiples of 12 times.  

In the On Current event I have the code <strCurrentSubform = strPageAfrm>, etc.  (without the <>)

I found posts where I can reference the subform by

forms(strCurrentSubform)            <forms(variableformysubform)>

but I need to refer to the subform by also including the name of the parent form, I suppose.  (Access tells me I have to do something different!)

Please write answers in general terms--  (like what I have above in < >).  I think everyone understands that better than trying to use my actual terms.  

Thanks!
Susan
Avatar of Stephen_Perrett
Stephen_Perrett

This is what I think you want

forms(strParentForm).form.controls(strSubform).form.controls(strControlName)

Steve
Avatar of skennedy10

ASKER

Steve,
Thanks for a quick reply.  

I don't really need to refer to the main form or the control by variable names (although I will right now since I have to show my product tomorrow morning!), so can I refer to some by the "collection" and other parts not?
Susan
Avatar of Hamed Nasr
You can use Forms!ParentForm!SubForm.Form to set the subForms’s properties.

Forms!ParentForm!SubForm!Control to refer to a control on the subForm.
ASKER CERTIFIED SOLUTION
Avatar of Stephen_Perrett
Stephen_Perrett

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, Stephen.  I'm just now getting into understanding collections and variables within them are definitely different!  

Great and fast!  (This is why ee is my homepage!)
Susan
Great! I agree ee is so useful

Steve