Clearing all comboboxes on a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Anyone know how to clear all unbound comboboxes on a form with VBA? I don't
even know how to do one. Maybe remove item. Plus, sometimes it populates items
then leaves them in the combobox in the properties window
 
This assumes the code goes somewhere in the module of the form, e.g. in the
Click event of a comand button on the form:

Dim ctl As Control
For each ctl in Me.Controls
If ctl.ControlType = acCombobox Then
If len(ctl.ControlSource) = 0 Then
ctl.Value = Null
End If
End If
Next
Set ctl = Nothing
 
Thanks. Thats works great. The only problem I see is that sometimes the
rowsource doesn't clear. Do I have to clear them with literals, ex:
me.combo1.rowsource = ""
me.combo2.rowsource = ""

I don't know why they 'stick'
Access forms have a lot of annoying features like this.
 
You should be able to clear the combo's Value (so the combo is blank -
nothing chosen), without needing to mess with its RowSource (the items in
the list to choose from).
 
Back
Top