Print Page | Close Window

SubformReference.mdb ( Beginner )

Printed From: Roger's Access Library
Category: Roger's Access Library
Forum Name: Roger's Download Samples
Forum Description: A compendium of Microsoft Access 97 and 2000+ routines, each separated into its own sample database.
URL: www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=261
Printed Date: 16 Apr 2024 at 1:06pm
Software Version: Web Wiz Forums 12.03 - http://www.webwizforums.com


Topic: SubformReference.mdb ( Beginner )
Posted By: Roger Carlson
Subject: SubformReference.mdb ( Beginner )
Date Posted: 21 Jul 2008 at 10:50pm

Please consider donating $1 per sample downloaded, http://www.rogersaccesslibrary.com/whydonations.htm - 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): http://www.rogersaccesslibrary.com/forum/uploads/5/SubformReference97.zip - uploads/5/SubformReference97.zip
Access 2000 (48 KB): http://www.rogersaccesslibrary.com/forum/uploads/5/SubformReference2k.zip - uploads/5/SubformReference2k.zip


-------------
Consider donating $1 per sample downloaded, http://www.rogersaccesslibrary.com/whydonations.htm" rel="nofollow - find out why here .<



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 - http://www.webwizforums.com
Copyright ©2001-2019 Web Wiz Ltd. - https://www.webwiz.net