Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clear forms

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello
This is a text I found regarding clearing all text fields in a form. I have created a button called CLEAR in my form with name=CLEAR and caption=CLEAR. Could anyone tell me where to append the following code? There is already a function called Private Sub CLEAR_Click()

End Sub
opened in my form. The text is:

To use code to clear all text boxes on a form, type the following in the form's code window, and call it from the desired event or function:
Private Sub ClearTextBoxes( )
Dim ctl As Control
For Each ctl in Me.Controls
If TypeOf ctl is Textbox Then
ctl.Text = '' ''
End If
Next ctl
End Sub
 
You can do 1 of 2 things: Remove the "subs" name of your new "function" and slip it in between Private Sub CLEAR_Click() and End Sub Or
Paste it anywhere on its own and add this between Private Sub CLEAR_Click()
ClearTextBoxes
and End Sub.


Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top