Listbox problem

P

PeterM

I have the following code setup. My form has 5 listboxes on them named LB1
thru LB5. All listboxes are single select. The code simply captures which
listbox has been clicked (onClick event) then it does some stuff (not
included in following code) and finally deselects the entry in the listbox.
It's giving me fits. It will not deselect the entry.

Can anyone tell me what I'm doing wrong? thanks

Dim ctlCurrentControl As Control
Dim strControlName As String
Dim intCurrentRow As Integer
Dim tmp_selected As Integer
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name
tmp_selected = Me(strControlName).ListIndex
Me(strControlName).SetFocus
For Each varItem In ctlCurrentControl.ItemsSelected
ctlCurrentControl.Selected(varItem) = False
Next varItem
Set ctlCurrentControl = Nothing
 
P

PeterM

Thanks for the response. However, I don't want to remove the entry from the
listbox, just to deselect it. Do you see anything in my code that I'm doing
wrong?
 
J

John W. Vinson

Thanks for the response. However, I don't want to remove the entry from the
listbox, just to deselect it

That is precisely what setting the listbox to Null does: deselects the
selected row, leaving no row selected - i.e. a NULL value.

The data is still there unchanged, just not selected.
 

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