Run Update or Delete in MS Access SQL


Wed May 25 2022 11:53:37 GMT+0000 (Coordinated Universal Time)

Saved by @paulbarry

Dim dbs As DAO.Database
Dim lngRowsAffected As Long
Dim lngRowsDeleted As Long

Set dbs = CurrentDb

' Execute runs both saved queries and SQL strings
dbs.Execute cstrQueryName, dbFailOnError

' Get the number of rows affected by the Action query. 
' You can display this to the user, store it in a table, or trigger an action 
' if an unexpected number (e.g. 0 rows when you expect > 0).
lngRowsAffected = dbs.RecordsAffected
dbs.Execute "DELETE FROM tblMyTable WHERE Bad", dbFailOnError
lngRowsDeleted = dbs.RecordsAffected

Update or Delete MS Access SQL