Newbee needs help - How to delete Current record on a recordset lo

N

Newbee Adam

when looping through a table in Access , can I use a statement to tell access
to update or delete the current record the loop is on.
something like :

DoCmd.RunSQL ("DELETE * FROM this record)
 
F

fredg

when looping through a table in Access , can I use a statement to tell access
to update or delete the current record the loop is on.
something like :

DoCmd.RunSQL ("DELETE * FROM this record)

Something like this.

Dim Db As DAO.Database
Dim rs As DAO.Recordset
Set Db = CurrentDb
Set rs = Db.OpenRecordset("TableName")

With rs
.MoveFirst
Do While Not .EOF
If !FieldName = SomeCriteria Then
rs.Delete
End If
rs.MoveNext
Loop
End With

Exit_This_Sub:
Set Db = Nothing
Set rs = Nothing
Exit Sub
 
N

Newbee Adam

thank you both.

Yes I see waht you me Lynn, I was thinking since it was in a loop it would
know to just delete the current record.
So instead of sql I did of corse :
rs.delete simple as it is, guess that is why they call me newbie!!!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top