Clear Button in a Form-Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created the Clear button in a form. On the ONCLICK properties field, I
want to use the Code Builder option. Does anybody know the code to clear the
fields in the form?
 
If you have a bound form, doing so will destroy the data in the current record.
Other than that, you can loop through the controls and set them to Null if
they are a control that can contain data.
 
I have created the Clear button in a form. On the ONCLICK properties field, I
want to use the Code Builder option. Does anybody know the code to clear the
fields in the form?

What's the context, Alexandra? Do you want to move to the new (blank)
record, or erase whatever information the user has entered, or what?

John W. Vinson[MVP]
 
To delete whatever info the user has entered to get all the fields in the
form blank and start all over
 
To delete whatever info the user has entered to get all the fields in the
form blank and start all over

Ok, two ways:

1. Train the user to hit the <Esc> key twice. No code needed.

2. Use a command button, cmdClear let's say, with one line of code:

Private Sub cmdClear_Click()
Me.Undo
End Sub


John W. Vinson[MVP]
 
Disregard the "you can't do this" response. It is either SPAM or something
worse. Follow the link at your own peril!

The person posting the response has used several different aliases, and is
now representing him/herself as an MVP.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top