Delete Rows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abdulkarim
    New Member
    • Apr 2008
    • 4

    Delete Rows

    I have tried to delete rows in a table with same ID in access database by using the following vb code with a click on command button, but it deletes only a single row instead of entire rows with same ID. Kindly help me to solve this problem.

    Set rst = dbs.OpenRecords et("select * from Bills where Bill_ID =" _
    & Me.cbid)
    With rst
    If Not .EOF Then
    .delete
    End If
    End With
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    you need to use a while loop instead of the if

    [code=vb]
    while not .EOF
    'Do your deleting stuff
    .MoveNext
    wend
    [/code]

    Having said that, why don't you just do this
    [code=vb]
    dbs.Execute "DELETE * from Bills where Bill_ID =" & Me.cbid
    [/code]

    Comment

    Working...