Clear text box value

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
 
S

Sandra Daigle

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!)
 
D

Daniel

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
 

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

Top