Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
nothing selected in listbox, but listindex < -1
I have a multicolumn listbox on a userform. When the user selects an item,
text boxes are then filled in from the selected item. I assumed if no item was highlighted in the listbox, then the listbox.listindex would be -1. There are situations, however, where nothing is selected but the listbox has a listindex of whatever the most recently selected item was. any ideas of what's going on here? Is there some way I can check to make sure something is "highlighted" in the listbox? thanks, Steve |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
nothing selected in listbox, but listindex < -1
I've narrowed it down to this: The list box becomes record becomes
"unselected" when I press the Update button. The update button takes values from a text box, tbMeshQuantity, and updates column (1) of the selected record. When this button is pressed, the record is updated, but then unselected. The listbox thinks it's still selected though. Code for the Update button below. Private Sub cbUpdate_Click() If Me.lbMeshShoppingCart.ListIndex = -1 Then MsgBox "select an item first" Exit Sub End If With Me.lbMeshShoppingCart .ColumnCount = 2 .ColumnWidths = "75;75" .List(.ListIndex, 1) = Me.tbMeshQuantity.Value End With End Sub "steve" wrote: I have a multicolumn listbox on a userform. When the user selects an item, text boxes are then filled in from the selected item. I assumed if no item was highlighted in the listbox, then the listbox.listindex would be -1. There are situations, however, where nothing is selected but the listbox has a listindex of whatever the most recently selected item was. any ideas of what's going on here? Is there some way I can check to make sure something is "highlighted" in the listbox? thanks, Steve |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
nothing selected in listbox, but listindex < -1
Ok, I think I got it. Each time I was pressing Update, I was setting the
..columncount property and .columnwidths property. This was taking the focus off of the selected record. I moved these items to the Form Initialize event, and everything seems to be working. Please let me know if someone has something else to add. -steve "steve" wrote: I've narrowed it down to this: The list box becomes record becomes "unselected" when I press the Update button. The update button takes values from a text box, tbMeshQuantity, and updates column (1) of the selected record. When this button is pressed, the record is updated, but then unselected. The listbox thinks it's still selected though. Code for the Update button below. Private Sub cbUpdate_Click() If Me.lbMeshShoppingCart.ListIndex = -1 Then MsgBox "select an item first" Exit Sub End If With Me.lbMeshShoppingCart .ColumnCount = 2 .ColumnWidths = "75;75" .List(.ListIndex, 1) = Me.tbMeshQuantity.Value End With End Sub "steve" wrote: I have a multicolumn listbox on a userform. When the user selects an item, text boxes are then filled in from the selected item. I assumed if no item was highlighted in the listbox, then the listbox.listindex would be -1. There are situations, however, where nothing is selected but the listbox has a listindex of whatever the most recently selected item was. any ideas of what's going on here? Is there some way I can check to make sure something is "highlighted" in the listbox? thanks, Steve |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Listindex problems in multicolumn listbox | Excel Programming | |||
ListBox and ListIndex | Excel Programming | |||
Select Listindex from column A on selected row | Excel Programming | |||
listbox listindex problem | Excel Programming | |||
listbox.value not equal to listbox.list(listbox.listindex,0) | Excel Programming |