Consulting

Results 1 to 2 of 2

Thread: How do you tell if a list box item has been "deselected"?

  1. #1

    Question How do you tell if a list box item has been "deselected"?

    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

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •