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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me to clear the contents of field with function or vba

Status
Not open for further replies.

HockeyFan

MIS
Jun 21, 2005
138
US
On a form, I would like to click a button, i want it to clear the contents of almost all of the fields on the form. Since I don't want it to clear all of the field, I will need a command that I can specify which fields to clear the contents from.
I couldn't find a function or command to do this and I don't know if it will have to be in vba or not? Please help.
 
Use the Tag property of the controls you want to clear:
Code:
For Each ctl In Me.Controls
  If ctl.Tag = "ClearMe" Then
    ctl.Value = Null
  End If
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The only problem is, that i wanted to clear the contents of specific fields upon clicking a button. I'm not sure how to adapt your code to do that.

do you see either of these lines to work for me? i've been looking at past posts.
note: I'm somewhat of a beginner at vb.


Me.TextboxName = ""

IsNull(Me.TextboxName)
 



"I would like to click a button"
"I'm not sure how to adapt your code to do that."

put PHV's code in your Button_Click

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top