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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to loop thru controls on a Tabbed Dialog Control

Status
Not open for further replies.

AGP

Programmer
Sep 11, 2001
97
0
0
GB
On a form containing a tabbed dialog control, I need to individualy loop through all the text boxes, check boxes and combo boxes placed on the tabbed dialog control. However, for example when trying to loop through all the text boxes in the following way I get an error;

Dim txt as TextBox

For Each txt in form1
txt.text = "some value"
Next


For some reason it seems to include each tab as a txt control and gives a type mismatch error. In addition in the above code I am looping through all the text controls on the form rather than those just placed on the tabbed dialog control. How do I just reference those contained on the tabbed dialog control?
many thanks.
 
AGP

This is how you can loop through the tabs but i do not know how you can loop through the controls within a tab as the form is the parent or container of text boxes that you put in a tab

For i = 0 To sstabs
SSTab1.Tab = i 'go to tab
MsgBox SSTab1.Caption

For Each txt In xx

Next
Next
 
Try
Dim objCon As Object
Set objCon = whateverTab
Dim txt as TextBox
For Each txt in form1
if txt.Container Is objCon Then
txt.text = "some value"
End If
Next
Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
JohnYingling's code works apart from the dim txt as textbox which generates a type mismatch error. Just the data type or check that control is of textbox type as below & it should work:

Dim txt As Control
For Each txt In Form1
If TypeName(txt) = "TextBox" Then
If txt.Container Is objCon Then

txt.Text = "some value"
End If
End If
Next
 
thanks for the help. Your answers have solved what I was trying to do! thanks again.
agp.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top