ListView Checkbox Click Question
Hi Everyone,
Is there an easier way of doing this? Sometimes when this code runs I get an error: Object block or with variable block not set. Other times it runs just fine. Anyways, what I am trying to do is get a sql statement to run when a user selects or deselects any check box in the ListView. I can't seem to figure out how to get it to work without looping through the ListView each time. I would appreciate any help. Thanks.
Code:
Private Sub lvwHistory_ItemCheck(ByVal Item As MSComctlLib.ListItem)
Dim objItem As ListItem
For Each objItem In lvwHistory.ListItems
If objItem.Checked = True Then
mcnAP.Execute "UPDATE DateRegister SET Void = Yes WHERE ID = " & objItem.Tag & ""
Else
mcnAP.Execute "UPDATE DateRegister SET Void = No WHERE ID = " & objItem.Tag & ""
End If
Next
End Sub