Clear All - Command Button Help Please

G

Guest

I have a form with 4 bound comboxes and a subform that displays the data
depending on the selections made in the comboxes. How do I create a command
button to clear all or any selections made in the comboxes and on the
subform, so that a new selection can be made.

Anyones assistance would be greatly appreciated.

Thanks
 
A

Arvin Meyer [MVP]

Try something like this:

Private Sub cmdClearCombos_Click()
On Error Resume Next
Dim ctl As Control

For Each ctl In Me.Controls
If ctl.ControlType = acComboBox Then
ctl = ""
End If
Next

End Sub
 
G

Guest

This works in which all the combo boxes are cleared, however it takes away my
ability to select individually or in combination from any of the comboxes
once the previous information is cleared.
 
A

Arvin Meyer [MVP]

You should be able to reselect any value in any of the combo boxes. A
subform is merely a control until it has focus, then it becomes a form, so
you'd have to add another code snippet to take care of the form property of
the subform control. I haven't done this before but, I'd try a bit of code
something like:

For Each ctl In Me.NameofSubformControl.Form.Controls
If ctl.ControlType = acComboBox Then
ctl = ""
End If
Next

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 

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