How to list all controls in a page of a tab control.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How is this done and how do I obtain the name and type of the control.
By type I mean say label or text etc.
 
ThomasAJ said:
How is this done and how do I obtain the name and type of the control.
By type I mean say label or text etc.


For Each ctl In Me.tabcontrol.Pages(N).Controls
Debug.Print ctl.Name, ctl.ControlType
Next ctl

The currently display page number of a tab control is the
value of the table control. I.e.
Me.tabcontrol.Pages(Me.tabcontrol).Controls

Note that the type is a integer. You would have to create a
function to convert the number to text. See ControlType in
Help for details.
 
How is this done and how do I obtain the name and type of the control.
By type I mean say label or text etc.

Tools... Analyze... Documentor will do it; or you can loop through the
Form's Controls collection. There are VBA constants for each control
type - they're not terribly intuitive though! You may need to use an
expression like

Dim iType As Integer
Dim sType As String
Dim ctl As Control
For Each ctl In Me.Controls
iType = ctl.Properties("ControlType")
sType = Switch(iType = acTextbox, "Textbox", _
iType = acLabel, "Label", _
iType = acCheckbox, "Checkbox", _
<and so on>
Debug.Print ctl.Name, sType
Next ctl



John W. Vinson[MVP]
 

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

Back
Top