SubformReference.mdb (Beginner)

Please consider donating $1 per sample downloaded, find out why here
Download
SubformReference.zip
Access 97 (27 KB)
This sample illustrates how to reference controls 
on subforms and subsubForms.  It also illustrates 
how to set the focus to these controls.  

The problem with referencing controls on subforms 
is usually with the naming and which controls you 
are referencing.  You never reference the actual 
subform name, you reference the name of the 
control which holds the subform.  So let me use 
some more generic names:

"Form1" has a control on it "SubControl1" which 
holds "Subform1".  This subform has a control on 
it called "SubsubControl1" which holds 
subform "Subsubform1", which has a control on it 
called "txtAmount"

So we have a form, with a subform which holds a 
subform.  The command to reference the text box 
on the bottom-most form would be:

   Forms!Form1!subControl1.Form!subsubControl1.Form!txtAmount

Notice, at no time do I refer the name of either 
subform, just the controls which hold them.  Now 
this gets confusing, because Access has a 
tendency to name the control the same as the 
subform.  This is why I always name the control 
something other than the name of the subform to 
avoid confusion.

To set the Focus to a control on a subform, you 
must first set focus to the Control on the main 
form which holds the subform and then the control
on the subform.

 

Feedback

 

Need Winzip?

Return to Main Page