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

Clear forms field values on Focus 2

Status
Not open for further replies.

lreedy

Programmer
Jan 4, 2001
8
0
0
US
I apoligize in advance if this is a duplicate question, but the search function has been down for DAYS.

I have a form that has several text boxes that allow the user to enter search criteria for my table. When the user hits the find button, another form is displayed with a listbox of all the matching items. If the user hits ESC or exit to return to the previous form to reenter his search criteria , I need to know how to clear all the fields of his previously entered data.

Thank you,
 
There are a couple of ways to do this. One is to set each control value to Null.

Me.ControlName = Null

Another way is to iterate through the controls and for those that match a specific control type set their value to null.

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acListBox Or Ctl.ControlType = acCombobox Then
With ctl
.Value = Null
End With
End If
Next ctl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top