Roger's Access Library Homepage
Forum Home Forum Home > Roger's Access Library > Roger's Download Samples
  New Posts New Posts RSS Feed - SubformReference.mdb ( Beginner )
  FAQ FAQ  Forum Search   Events   Register Register  Login Login


Please consider donating $1 per sample downloaded, (find out why here)

SubformReference.mdb ( Beginner )

 Post Reply Post Reply
Author
Message Reverse Sort Order
Roger Carlson View Drop Down
Microsoft MVP
Microsoft MVP


Joined: 20 Feb 2008
Status: Offline
Points: 249
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roger Carlson Quote  Post ReplyReply Direct Link To This Post Topic: SubformReference.mdb ( Beginner )
    Posted: 21 Jul 2008 at 10:50pm

Please consider donating $1 per sample downloaded, find out why here.
 

SubformReference.mdb

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.

Download
Access 97 (27 KB): uploads/5/SubformReference97.zip
Access 2000 (48 KB): uploads/5/SubformReference2k.zip
Consider donating $1 per sample downloaded, find out why here.<
Back to Top
Sponsored Links


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down