Results 1 to 6 of 6

Thread: Collections problem - Resolved!!!

  1. #1

    Thread Starter
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935

    Collections problem - Resolved!!!

    hi all I cant quite figure out what i have done wrong with the following code............... anybody who can point out where i have messed up would be appreciated

    VB Code:
    1. Private Sub clrTxtBoxes()
    2. Dim frm As Form
    3. Dim ctl As TextBox
    4.    
    5.     Set frm = Form1
    6.    
    7.     For Each ctl In frm
    8.         ctl.Text = ""
    9.     Next ctl
    10.  
    11. End Sub

    Thanks in advance
    Last edited by rudvs2; Oct 16th, 2001 at 08:30 PM.

  2. #2
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Private Sub clrTxtBoxes()
    Dim ctl As TextBox

    For Each ctl In Controls
    ctl.Text = ""
    Next ctl

    End Sub

    hows that?

  3. #3

    Thread Starter
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    thanks beacon but still no luck i just get a type mismatch error when it trys to execute the For-Next loop



  4. #4
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Dim ctl As Control

    My bad!

    You may need this if your just doing text boxes:

    For Each ctl In Controls
    If (TypeOf ctl Is TextBox) Then
    ctl.text = ""
    End If
    Next

  5. #5

    Thread Starter
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    BINGO

    Thanks Beacon that did the trick perfectly

  6. #6
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    N.P

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