Controls in/outside a tab control on a form

J

Jess

I have a form with a tab control. This form also has additional controls
outside this tab control.

How can I know programmatically whether a given control on this form is in
the tab control or not? If a given a control is in the tab control, how can I
know programmatically which page this control belongs to?
 
J

Jack Leach

I'm not sure this is possible. Programatically, it doesn't matter if the
control is on a tab or not... everything is referred to as if the tab control
doesn't exist. You may want to implement a naming scheme or a tag value to
these controls as a way to help you with that.

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
D

Dale Fye

The controls parent.Name property will indicate either a the tab control page
name or the form name (at least it does in 2007).

?forms(Formname).ControlName.parent.name

I give all of may tab controls names that start with tab, and all of my
forms names that start with frm.
 
K

Krzysztof Naworyta

Jess wrote:
| I have a form with a tab control. This form also has additional
| controls outside this tab control.
|
| How can I know programmatically whether a given control on this form
| is in the tab control or not? If a given a control is in the tab
| control, how can I know programmatically which page this control
| belongs to?


Private Sub Command1_Click()

Dim ctr As Control
Dim ob As Object

For Each ctr In Me.Controls
Select Case ctr.ControlType
Case acPage, acTabCtl
Case Else
Set ob = ctr
Do
Set ob = ob.Parent
If TypeOf ob Is Page Then

Debug.Print ctr.Name, "page:" & ob.Name, ob.Caption
Debug.Print ,"index:", ob.PageIndex, "tab:", ob.Parent.Name
GoTo lab1:
End If
Loop Until TypeOf ob Is Form
Debug.Print ctr.Name, "OnForm"
End Select
lab1:
Next


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top