Deleting Item from ListView Field from MS-Access Table
Hi Guys,
I'm wondering on how to delete an item in the ListBox that field from the Table MS-Access.
VB Code:
Private Sub CmdDelete_Click()
Call OpenConn
If Me.List1.ListIndex = -1 Then
MsgBox "You should select a Level to delete", vbExclamation, "Delete Level"
Else
Me.List1.RemoveItem Me.List1.ListIndex
RSLevels.Open "Levels", Conn, adOpenDynamic, adLockOptimistic, adCmdTable
With RSLevels
If Not (.BOF = True Or .EOF = True) Then
.Delete adAffectCurrent
If Not (.BOF = True Or .EOF = True) Then
.MoveNext
If .EOF Then RS.MoveLast
.Requery
Me.List1.Refresh
.Close
End If
End If
End With
End If
End Sub
I've used the above code, it's deleted the select item from the ListBox perfectly, but once you cameback to the Form you will notice that the Item deleted is the First Item in the Table.
Can anyone help to delete the Selected Item from the ListBox as well as from the Table ??
Many Thanks in advance,
habibalby