By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,640 Members | 2,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,640 IT Pros & Developers. It's quick & easy.

Delete Rows

P: 4
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.OpenRecordset("select * from Bills where Bill_ID =" _
& Me.cbid)
With rst
If Not .EOF Then
.delete
End If
End With
Apr 11 '08 #1
Share this Question
Share on Google+
1 Reply


Delerna
Expert 100+
P: 1,134
you need to use a while loop instead of the if

Expand|Select|Wrap|Line Numbers
  1. while not .EOF
  2.    'Do your deleting stuff
  3.     .MoveNext
  4. wend
  5.  
Having said that, why don't you just do this
Expand|Select|Wrap|Line Numbers
  1. dbs.Execute "DELETE * from Bills where Bill_ID =" & Me.cbid
  2.  
Apr 11 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.