Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referring to controls within SubForms and Tab Controls

Status
Not open for further replies.

scriverb

Programmer
May 17, 2002
4,485
US
I am assisting a friend with a database that has the following:
MainForm(frmMain), SubForm(frmSF1), a Tab Control with 3 pages, the third page has a subform(frmTCSF1).

The subform on the 3rd page of the tab control has a continuous form displaying a number of records. A command button in each row when clicked should return the focus to the 1st page of the tab control to a control named [RecipID]. There are other things necessary to be performed but the first step is to just understand the referencing of controls given the above situation. So if we can just transfer the focus from this nested subform continuous form command button to other locations on the form( frmMain, frmSF1, etc.) we can probably figure out the rest. We have tried many combinations but have not found one that works.

I have tried the simple Forms![frmMain].ControlName to transfer focus up to the main form and that doesn't work. (Error: This object doesn't support the method)

I am a little stumped here as I don't use the tab control much but am willing to learn through this posting. Need a little help TT guys.

Bob Scriver
 
To refer to a property of a subform on a tab page, you use:

[Subform Control Name].Form.Property

To refer to a control on a subform on a tab page:

[Subform Control Name].Form![Control Name]

And, to refer to a property of a control on a subform on a tab page:

[Subform Control Name].Form![Control Name].Property
 
Trying to test this I am trying to set the focus to a control RecipID. I have put a button on the frmMain to transfer control down to this control:

Me.[frmSF1].Form![TabCtl16].[RecipID].SetFocus

The form and control nexting is as follows:
frmMain - Command Btn
frmSF1 - SubForm control on frmMain
TabCt116 - TabControl on a form named frmCase
This frmCase is the Source Object for frmSF1
RecipID - Text control on the 1st Page of TabCt116

The error being received is: Object doesn't support this property or method.

Bob Scriver
 
You may need to activate the page (via the page index/tab control value) prior to the .SetFocus of the control....this is from help:

Private Sub TabCtl0_Change()
Dim tbc As Control, pge As Page
Dim ctl As Control

' Return reference to tab control.
Set tbc = Me!TabCtl0
' Return reference to currently selected page.
Set pge = tbc.Pages(tbc.Value)
' Enumerate controls on currently selected page.
Debug.Print pge.Name & " Controls:"
For Each ctl In pge.Controls
Debug.Print ctl.Name
Next ctl
Debug.Print
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top