|
-
Aug 18th, 2000, 01:18 PM
#1
Thread Starter
Junior Member
I'm trying to loop thru' all of the textboxes on a form to set their text properties to "". However, I keep getting an object error. I've checked the online help and searched this site yet I still can't seem to find the problem. Can you please show me an example, including the Dim Statements, of using For Each...Next. FYI, programming in Word 2000 vba.
Thank you.
-
Aug 18th, 2000, 01:37 PM
#2
Monday Morning Lunatic
This should work:
Code:
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
ctl.Text = ""
End If
Next
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 18th, 2000, 01:44 PM
#3
this also works
Code:
Private Sub CommandButton1_Click()
Dim TB As TextBox
For Each TB In Me.Controls
TB.Text = ""
Next TB
End Sub
-
Aug 18th, 2000, 01:55 PM
#4
If you declare it as a TextBox you'll get an error. Declare it as a Control instead.
-
Aug 18th, 2000, 02:00 PM
#5
oh yeah, I tried parksie's code and got it confused with mine... oops.... 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|