Full Version: how do you deselect a listbox, combobox
UtterAccess Forums > Microsoft® Access > Access Forms
GordMacDonald
Hi all,
How do you deselect an

a) listbox
b) combobox
Thanks,
Gord
freakazeud
Hi,
set it to null:
e.YourCombo = null
Me.YourListbox = null
HTH
Good luck
GordMacDonald
thanks!
Gord
freakazeud
You're welcome.
Good luck on future projects!
GordMacDonald
I have - alas - discovered that this method of clearing listboxes does not work when the Multiselect property is set to any value other than "None".
tried to workaround with the following code:
Me.geo_loc_id.MultiSelect = 0
Me.geo_loc_id = Null
Me.geo_loc_id.MultiSelect = 1
but this property can apparently only be set at design time.
Any suggestions on handling deselction of listboxes which are set to simple or extended?
Thanks,
Gord
freakazeud
Yes a multiselect listbox needs to be handled in a different manner.
Try this:
im varItm As Variant
With YourListBoxName
For Each varItm In .ItemsSelected
.Selected(varItm) = False
Next varItm
End With
HTH
Good luck
GordMacDonald
Thanks alot Freakazeud - I just got to your solution (I was wrestling with some other issues) - works great!
Gord
freakazeud
You're welcome.
Glad I could assist.
Good luck on future projects!
GordMacDonald
whew! - three different multilist states - three different deselect methods
mulitiselect is "None" = 0
MyListbox = null
mulitiselect is "Simple" = 1
must use the loop method:
Dim varItm As Variant
With YourListBoxName
For Each varItm In .ItemsSelected
.Selected(varItm) = False
Next varItm
End With
multilist is "Extended" = 2
Mylistbox.Requery
Gord
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.