• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

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
0
skennedy10
Asked:
skennedy10
  • 3
  • 2
1 Solution
 
Stephen_PerrettCommented:
This is what I think you want

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

Steve
0
 
skennedy10Author Commented:
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
0
 
hnasrCommented:
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.
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
Stephen_PerrettCommented:
You can refer to any using as a literal string e.g.

forms("NameOfMainForm").form.controls(strSubform).form.controls("NameOfControl")

Steve
0
 
skennedy10Author Commented:
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
0
 
Stephen_PerrettCommented:
Great! I agree ee is so useful

Steve
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now