Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Dallas plus 20 miles or so, Texas, USA
    Posts
    876
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Looping through form controls (2000)

    Is there a better way to loop through the textboxes in a userform and change their values? This is the only way I could get it done.

    <pre>For Each Control In Entry.Controls
    If Left(Control.Name, 4) = "Text" Then
    Control.Value = ""
    End If
    Next
    </pre>


  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Looping through form controls (2000)

    There is a TypeName Function which you can use as follows :

    For Each Control In Entry.Controls
    If TypeName(Control) = "TextBox" Then
    Control.Value = ""
    End If
    Next


    Andrew C

  3. #3
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Dallas plus 20 miles or so, Texas, USA
    Posts
    876
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Looping through form controls (2000)

    Thanks Andrew, I picked that up from a link in a search. I take it there is no way to do the following:

    Dim tob as Textbox
    For each tob in Userform1.Controls
    tob.Value=""
    Next

    Thanks,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •