Ken Puls
12-08-2004, 09:49 AM
Hi guys,
Ran into a small issue with a listbox that I can't figure out. I have two listboxes on a form, which list the column heading for the spreadsheet. I need the user to pick one in each listbox, but they have to be different.
I pulled the following routine together to ensure that if a user picks the same two values, that the listindex of the second box (lbSort) will be set back to -1. While this effectively resets the box, the line still appears as highlighted. I've played with the "selection" property but just can't seemed to clear it!
Code to date:
Private Sub Utility_Check_ListItems()
'Ensure that lbSort does not have same item selected as lbUnique
If lbUnique.ListIndex = lbSort.ListIndex Then
MsgBox "Sorry. You cannot choose the same column for both choices.", _
vbOKOnly + vbCritical, "Try again!"
lbSort.ListIndex = -1
End If
End Sub
I know that I can clear and recreate the listbox values, but this seems like it should be unnecessary. Any idea how to just unselect the selection?
Thanks,
Ran into a small issue with a listbox that I can't figure out. I have two listboxes on a form, which list the column heading for the spreadsheet. I need the user to pick one in each listbox, but they have to be different.
I pulled the following routine together to ensure that if a user picks the same two values, that the listindex of the second box (lbSort) will be set back to -1. While this effectively resets the box, the line still appears as highlighted. I've played with the "selection" property but just can't seemed to clear it!
Code to date:
Private Sub Utility_Check_ListItems()
'Ensure that lbSort does not have same item selected as lbUnique
If lbUnique.ListIndex = lbSort.ListIndex Then
MsgBox "Sorry. You cannot choose the same column for both choices.", _
vbOKOnly + vbCritical, "Try again!"
lbSort.ListIndex = -1
End If
End Sub
I know that I can clear and recreate the listbox values, but this seems like it should be unnecessary. Any idea how to just unselect the selection?
Thanks,