Clear a Text Box with a button

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
If you have a Textbox on a Form that is tied to Table, can you clear that Textbox by creating an event associated with a button?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
If the field is "bound" to a table, clearing that Textbox will remove that value from the table field for whatever record you are viewing at the time.

If that is what you want to do, simply add a button, and then add code to the Click event of the button that will remove it, i.e.
Code:
Private Sub Command23_Click()
    Me.TextBox1 = ""
End Sub
 
Last edited:
Upvote 0
What if you wanted to clear an entire column in a table (a Yes/No field). Button would rest them all to "No"
 
Upvote 0
You would probably want to use an Unbound for that, and have your your button run the code to do that.

An easy way would be to make an Update Query that does what you want (set the value of a field to blank).
And then just have your button run this Query.
 
Upvote 0

Forum statistics

Threads
1,221,773
Messages
6,161,855
Members
451,724
Latest member
sledparty

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top