akidragon
02-07-2010, 09:23 PM
Hi, I have a question regarding the DblClick Event in VBA Excel.
Basically, what I am trying to do is:
1. Trigger the DblClick event when an item in a multiselect listbox is double clicked
2. At the end of the event, I would like to deselect all items in the listbox including the item that was double clicked.
Now I have no problems with #1, but I am struggling with #2.
This is what I tried doing:
Sub lb1_DblClick()
...... (several statements which runs ok)
'End of event - deselect all
For i = 0 To lb1.ListCount - 1
lb1.Selected = False
Next i
End Sub
Now this does deselect all the items in the listbox but the "square" remains around the clicked item, and it seems this is because I am still in the DblClick event. Anyway to get rid of this square?
FYI: The reason I am asking this seemingly unnecessary issue is because I am trying to repopulate this listbox with a SQL query to an Access DB at the end of the event and this seems to be interferring with the repopulation macro.
Basically, what I am trying to do is:
1. Trigger the DblClick event when an item in a multiselect listbox is double clicked
2. At the end of the event, I would like to deselect all items in the listbox including the item that was double clicked.
Now I have no problems with #1, but I am struggling with #2.
This is what I tried doing:
Sub lb1_DblClick()
...... (several statements which runs ok)
'End of event - deselect all
For i = 0 To lb1.ListCount - 1
lb1.Selected = False
Next i
End Sub
Now this does deselect all the items in the listbox but the "square" remains around the clicked item, and it seems this is because I am still in the DblClick event. Anyway to get rid of this square?
FYI: The reason I am asking this seemingly unnecessary issue is because I am trying to repopulate this listbox with a SQL query to an Access DB at the end of the event and this seems to be interferring with the repopulation macro.