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

objects in active userform

Status
Not open for further replies.

rgandy

Technical User
Nov 17, 2005
38
US
i would like to iterate thru all drop down boxes and text boxes in the current active userform

i imagine the syntax is something like..

for each blahblah in userforms(activeuserform)
blahblah.value = ""
next blahblah

does anyone know the exact syntax? thanks
 
A starting point:
For Each objForm In UserForms
If objForm.Visible Then
For Each objControl In objForm.Controls
MsgBox "Form=" & objForm.Name & ", Control=" & objControl.Name
Next
End If
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Assume Userform named Userform1
Code:
Sub LoopUserformControls()
Dim Ctrl As Control

   For Each Ctrl In Userform1.Controls
     If TypeName(Ctrl) = "TextBox" Then
     ' Do stuff
     ElseIf TypeName(Ctrl) = "ComboBox" Then
     ' Do other stuff
     End If
   Next Ctrl
End Sub


Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top