Preview:
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
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter