UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Closed TopicStart new topic
> Referring to embedded form (subform) controls (Illustrated)    
 
   
niesz
post Dec 21 2009, 09:22 PM
Post#1


Utter A-fishin'-ado
Posts: 17,958
Joined: 1-August 05
From: Cincinnati, Ohio, USA . . . ><((((°>


Many times we have a need to refer to a control on an embedded form (commonly called a subform). Referring to that control can be challenging if we aren't familiar with how embedded forms are addressed.

In the following example, our main form is named "FormA" and our embedded form is named "FormB". FormB contains a textbox control named "MyTextbox".



To refer to the value in MyTextbox, we need to know two things: [*] the name of the main form [*] the name of the subform control

Even though our embedded form is named FormB, that may or may not be the name of the subform control that contains it. The subform control may be named differently.

To make sure, switch to Design View and click the border of the subform object to select the subform control. The subform control is selected when you see eight "selection dots" as shown in the picture. Notice the Name property in the Properties dialogue when the subform control is selected. This subform control is named "MyInnerForm".



Notice the distinction between selecting the subform control and the embedded form itself:



** IMPORTANT TO NOTE: The name of the embedded form is not used when referring to a control on it. Only the name of the subform control that houses it.

So, our syntax for referring to a control on an embedded form is:

CODE
Forms.MainFormName.SubFormControlName.Form.ControlName


Therefore to refer to the contents of MyTextbox located on FormB, we use:

CODE
Forms.FormA.MyInnerForm.Form.MyTextbox


Note that if your object names contain spaces or special characters, you'll need to enclose them in square brackets like:

CODE
Forms.[Form A].[Inner Form].Form.[My Textbox]


...but the preferred method is to avoid all spaces and special characters altogether and then bracketing never becomes an issue.


For a more comprehensive list of how to refer to controls on other objects, please see this link:
Refer to Form and Subform Properties and Controls

I would like to thank the many members of the Utter Access community who assisted with the development of this FAQ.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    18th December 2017 - 09:38 AM