Clear Button in a Form-Code

A

Alexandra504

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?
 
K

Klatuu

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.
 
J

John Vinson

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]
 
A

Alexandra504

To delete whatever info the user has entered to get all the fields in the
form blank and start all over
 
J

John Vinson

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]
 
J

Jeff Boyce

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
 
Top