Results 1 to 4 of 4

Thread: For Each Loops help!!

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Wink

    ok ok now that i got your attention. well it's not that bad
    {{{laughing}}}
    im trying to just simply trying to print out a list of textbox names that are on a form but all i can figure out
    is how to print every control name on a form.

    Dim txt as Object
    For Each txt In frmAccountSetup.Controls
    Debug.Print txt.Name
    Next txt

    ' is there anyway to get just the textbox names??
    Thanks All




  2. #2
    Guest
    Use TypeOf to check if it's a TextBox.
    Code:
    Dim txt As Control
    
    For Each txt In Controls
        If TypeOf txt Is TextBox Then Debug.Print txt.Name
    Next txt

  3. #3
    Lively Member
    Join Date
    Oct 2000
    Location
    Chicago
    Posts
    97

    Here is the solution

    Hi Dilenger4,
    Yes there is solution to find the names of all the textboxes present in a form.Here is the code..

    Dim ctl As Control

    For Each ctl In Me.Controls
    If TypeOf ctl Is TextBox Then
    Debug.Print ctl.Name
    End If
    Next

    Hope this will help you

    Regards
    Anil

  4. #4

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Ahhhhhhhh. I has once again been enlightened!
    Thanks..... =C)

Posting Permissions

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



Click Here to Expand Forum to Full Width