I am having trouble with allowing users to select multiple items in a Listbox and then allowing them to be removed after clicking a "Verify" button. If multiple items were selected, only the first selected item would be removed from the listbox after selecting the "Verify" button. The other selected items would be still highlighted. Any suggestions?
Here's the code for the verify button:
VB Code:
'*CMDVERIFY_CLICK()************************************************************ 'NAME: cmdVerify_Click() 'DESC: Allows the user to verify that they have counted the selected item(s). Private Sub cmdVerify_Click() Set connection = New ADODB.connection connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source= G:\Finance\Inventory Control\CycleCount\DB\cycleCount.mdb" connection.Open Set recordSet = New ADODB.recordSet Dim counter As Integer counter = lstVerificationScreen.ListCount - 1 Do While counter >= 0 If (lstVerificationScreen.Selected(counter) = True) Then Dim selectStatement, sSQL As String Dim strArray() As String strArray = Split(lstVerificationScreen.List(counter), vbTab, -1, 1) selectStatement = "SELECT * " & _ "FROM [MAIN] " & _ "WHERE ID=" & strArray(0) sSQL = "UPDATE [ALTER] SET TYPEOFCHANGE='DELETED' " & _ "WHERE [MAIN ID]='" & strArray(0) & "'" connection.Execute sSQL sSQL = "UPDATE TOGO AS t SET CHECKED = TRUE" & _ "WHERE PROD = '" & strArray(0) & "'" recordSet.Open selectStatement, connection If (recordSet.RecordCount = 1) Then selectStatement = "DELETE FROM [MAIN] WHERE ID=" & strArray(0) connection.Execute selectStatement End If lstVerificationScreen.RemoveItem (counter) End If DoEvents counter = counter - 1 Loop connection.Close Set recordSet = Nothing Set connection = Nothing End Sub '*ENDOF*CMDVERIFY_CLICK()******************************************************
Thank you.




Reply With Quote