Uhhighlight listbox items

selevanm

Matt
Local time
Today, 15:18
Joined
Mar 7, 2007
Messages
17
I have a listbox that the user makes a selection from. Based on that selection I fill in some hidden text boxes to gather the necessary data I need to send to a query that inserts records into my database. After the query has run I update the row source of the listbox to display the remaining list items. (the item the user selected is now gone from the listbox.) After the above process is done I would like to be able to unhighlight any item in the listbox because my process is dependent on the user selecting an item from the box. If the next record in the listbox remains highlighted the user thinks that it is selected. I have tried using the .selected(listitem) = false solution but it does not appear to work. The research I have done says this is the way to go but I am wondering if by updating the row source of the listbox and then requerying is causing some problems. I have also tried to set the selected property of the list item to false before updating the row source to no avail. Here is a snapshot of the code, I appreciate any assistance on this.

intIndex = Me.lstAssistRequests.ListIndex

<do stuff>

strSQLRowSource = "SELECT....."

Me.lstAssistRequests.RowSource = strSQLRowSource

Me.lstAssistRequests.Requery

Me.lstAssistRequests.Selected(intIndex ) = False

Matt
 
If you SQL is the same every time (i.e. it is set by the properties of the listbox), then all you need is the:

Me.lstAssistRequests.Requery.

Does this not work?
 
The requery portion works perfectly, the item selected from the listbox is removed. The problem lies in after the item is removed the next item in the listbox is highlighted. I want it be be unhighlighted so the user needs to explicity select the next item from the list box. I apologixe if I didnt explain myself very well, and thanks for the quick response.
 
This will clear the listbox, and force the user to choose again:
Me.lstAssistRequests.value = ""
 
Thanks Dr Snuggles, works like a charm....I love it when the answer is so simple and I make it more complex than it needs to be. Have a good day!
 
Clearing a ListBox will not change underlying table

This will clear the listbox, and force the user to choose again:
Me.lstAssistRequests.value = ""


I have a listbox on a form - when the user double-clicks the selection it will clear.

I have tried the code above (setting the value to " " ), but then when I print my report a space is printed rather than null. I am unable to set the value of the field to vbnullstring

The following code accomplishes deselecting the selection in the listbox, however, it does not accomplishes clearing the value in the underlying table. Therefore whenever I go back into the form, the original value is still there. Any suggestions as to how I can have the user deselect a listbox (it is not multi-select) and have a null value stored in the table?

Private Sub fldSystemCapacity_DblClick(Cancel As Integer)
On Error GoTo Err_Dblclick

Dim i As Integer
Dim ctl As Control

Set ctl = Me!fldSystemCapacity

For i = 0 To ctl.ListCount - 1

If ctl.Selected(i) Then
ctl.Selected(i) = False
End If
Next i


Exit_Dblclick:
Exit Sub

Err_Dblclick:
MsgBox Err.Description
Resume Exit_Dblclick


End Sub

--Thanks in advance!
Lisa
 

Users who are viewing this thread

Back
Top Bottom