• Looping through form controls (2000)

    Author
    Topic
    #368437

    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.

    For Each Control In Entry.Controls
        If Left(Control.Name, 4) = "Text" Then
            Control.Value = ""
        End If
    Next
    
    Viewing 0 reply threads
    Author
    Replies
    • #577310

      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

      • #577319

        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,

    Viewing 0 reply threads
    Reply To: Looping through form controls (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: