Results 1 to 17 of 17

Thread: Deleting Item from ListView Field from MS-Access Table

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    Bahrain
    Posts
    306

    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:
    1. Private Sub CmdDelete_Click()
    2. Call OpenConn
    3.  If Me.List1.ListIndex = -1 Then
    4.  MsgBox "You should select a Level to delete", vbExclamation, "Delete Level"
    5.  Else
    6.  Me.List1.RemoveItem Me.List1.ListIndex
    7.  
    8.  
    9. RSLevels.Open "Levels", Conn, adOpenDynamic, adLockOptimistic, adCmdTable
    10.  
    11.     With RSLevels
    12.           If Not (.BOF = True Or .EOF = True) Then
    13.          .Delete adAffectCurrent
    14.           If Not (.BOF = True Or .EOF = True) Then
    15.          .MoveNext
    16.           If .EOF Then RS.MoveLast
    17.          .Requery
    18.           Me.List1.Refresh
    19.          .Close
    20.           End If
    21.           End If
    22.    End With
    23.    End If
    24.    
    25. 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
    Last edited by Habibi; Nov 4th, 2004 at 07:10 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width