Clear text box value

  • Thread starter Thread starter Daniel
  • Start date Start date
D

Daniel

Hello All,

I have a form that has unbound text and combo boxes used to enter criteria
for queries. Not all boxes are used every time. Currently, I have to
manually delete the value in the box to enter different criteria. I need a
command button "Reset Form" that will delete or clear the value in each of
the boxes at the same time so I can start with blank text and combo boxes.

Thanks,

Daniel
 
You can start with a simple procedure that loops through all the controls on
the form and then sets the value to null:

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox _
Or ctl.ControlType = acComboBox Then
ctl = Null
ElseIf ctl.ControlType = acListBox Then
If ctl.MultiSelect = 0 Then
ctl = Null
End If
End If
Next ctl
set ctl=nothing

You will have to decide how you want to handle frames and checkboxes (and
anything else I've forgotten!)
 
Sandra,

It works great.......Thank you for your quick reply.

Daniel


Sandra Daigle said:
You can start with a simple procedure that loops through all the controls on
the form and then sets the value to null:

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox _
Or ctl.ControlType = acComboBox Then
ctl = Null
ElseIf ctl.ControlType = acListBox Then
If ctl.MultiSelect = 0 Then
ctl = Null
End If
End If
Next ctl
set ctl=nothing

You will have to decide how you want to handle frames and checkboxes (and
anything else I've forgotten!)

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Hello All,

I have a form that has unbound text and combo boxes used to enter
criteria for queries. Not all boxes are used every time. Currently,
I have to manually delete the value in the box to enter different
criteria. I need a command button "Reset Form" that will delete or
clear the value in each of the boxes at the same time so I can start
with blank text and combo boxes.

Thanks,

Daniel
 
Back
Top