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!

reset form using VBA 1

Status
Not open for further replies.

ad2

Technical User
Dec 31, 2002
186
US
Hi,

I want to have a button that resets all the controls on a form to blank when it is clicked. Is there a way to do this without listing each control in the Sub? Is there something like * for that would mean select all controls?

This is an example of what I have been using, but there are 20 controls on the form, so a short cut would be nice.

Private Sub cmdReset_Click()
Me!Control1.Value = ""
Me!Control2.Value = ""
End Sub

 
See thread702-1387630 for some code that may help.
 
Thanks, I've seen similar code used on the dirty event, but still too much coding.

I was wondering if there were any thing like on a query, when you use the * to select all fields from a table. Something like:

Private Sub cmdReset_Click()
Me.controls(*).Value = ""
End Sub

What I'm trying to get is a short cut for select all controls on the form and set the value to blank.
 
Have you tried just creating a command button with the wizard and selecting Record Operations/Undo Record?
 
Looping through the controls, as shown in the referenced thread, would contain the least code.
You would need to take into account that not all controls can take the same types of values, and you would need to check the control's type for that.


 
fneily,

This is just what I wanted. Thanks!

"Have you tried just creating a command button with the wizard and selecting Record Operations/Undo Record? "

Ad2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top