PDA

View Full Version : How do you tell if a list box item has been "deselected"?



LaurieL
08-06-2010, 01:27 PM
I have a list box that when items from it are selected, it writes data to another table. I need to also be able to have it delete records from the table when items are "deselected".

I tried using the following code to check if an item has been "deselected", but it's not working:

If lboHardwarePns.Selected(.ListIndex) Then
rstModuleUsesHRFileAndHardwarePart.FindFirst "Module_id=" & lngModuleId & " AND HRFile_id=" & lngHRFileId & " AND HardwarePart_id=" & .ItemData(.ListIndex)
If Not rstModuleUsesHRFileAndHardwarePart.NoMatch Then rstModuleUsesHRFileAndHardwarePart.Delete
End If

When I do a watch on "lboHardwarePns.Selected(.ListIndex)" it shows a value of 0 whether the item gets selected or deselected.

What am I doing wrong?

Thanks,

Laurie

OBP
08-07-2010, 10:23 AM
LaurieL, welcome to the Forum.
Shouldn't you be recording the "State" of the List Item in the "On Enter" or "On Got Focus" Events and then comparing them to the AfterUpdate Event "State" of the List?
That way you can establish a change of "State" in either direction.