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)
 
Ad

Advertisements

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
 
Ad

Advertisements

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!!!!!!!
 

Top