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

Viarables as object names

Status
Not open for further replies.

xyxex

Technical User
Sep 4, 2008
10
GB
I have a number of textboxes on a user for that I need to perform the same action on. I am trying to write a loop that will take a common part of the name and add a numbe to the end. This new text then becomes the textbox name

Private Sub Loop1()
Dim Coretext, Newtext
Coretext = "Textbox"
For i = 1 to 12
newtext = coretext & i
me.newtext.visible = false
Next
End sub

In theory textbox 1 to 12 should nowq be hidden but I cannot fugure out how to get VBA to accept "newtext" as object name
Thanks
 
Have you tried this ?
For i = 1 To 12
Me.Controls("Textbox" & i).Visible = False
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top