MS Access TabCtrl

Sigma248

Registered User.
Local time
Today, 13:12
Joined
Oct 6, 2008
Messages
24
How do you gain access to the value of a text box on a page of a TabCtrl.

I have tried variations of something like this and can't get it to work:

text box: txtTextBox
TabCtrl: TabCtl1
text box is on Page 0.
Form: Form1


TextBoxValue = Forms![Form1].TabCtl1.Page(0).txtTextBox
 
Pretend the tab control doesn't exist. You treat the control as if the tab control isn't even there.

So it would be

TextBoxValue = Forms!Form1.txtTextBox
 
My situation with the TabCtrl is now a little more complex:

I have 1 subform on each of 3 pages in the TabCtrl:

How do I access a textbox value on 1 of the subforms on 1 of the pages of the TabCtrl.

I have tried variations of:

textbox.value = Forms![Form1]![SubForm1].txtTextBox.Value

where

Main form = Form1
1st SubForm on Page 0 = SubForm1
 
if you are ON the main parent form, then simply

subformname!fieldname will pick up the vallue, where subformname is the name of the subform control on the parent form
 
if you are ON the main parent form, then simply

subformname!fieldname will pick up the vallue, where subformname is the name of the subform control on the parent form
You should use the .form. part between the subform container and control because you are telling Access that you want an object on the subform, not the subform container.
 
bob, i just checked to make sure

this syntax resolved correctly in the parent form, to reference a control on the subform

=subform_control_name_on_parent_form!control_on_subform
 
bob, i just checked to make sure

this syntax resolved correctly in the parent form, to reference a control on the subform

=subform_control_name_on_parent_form!control_on_subform

Again, this is one of those times where you can get yourself, and others, confused as to which syntax to use based on something that will work PART of the time and not 100% of the time. The code I suggest works 100% of the time and once learned can be applied to ANY situation, whereas yours will only work in limited situations and will only start to confuse and disorient people as to how subform syntax really works.

I use this to educate on how to use subform syntax:

1. When you are dealing with subforms, you are actually dealing with two parts - the subform CONTAINER (that which houses the subform on the main form) and the subform itself.

2. The subform and subform container can be named the same, but are not necessarily so. You need to check before writing the code. If they are the same then it simplifies things but it doesn't really matter if it is, or isn't, because you just have to refer to the container.

3. When you are doing things, like setting the recordsource on the subform, you are not really requerying the container, as it doesn't have a requery method, but the subform itself does. So, when you are referring to a property, or method, on the actual subform (not the container), you need to have the subform container name and then .Form. between the container name and the method, or property, so Access knows you want to refer to the form's method or property and not the container's method or property.
 

Users who are viewing this thread

Back
Top Bottom