Delete records without a confirmation message

A

Adam

In a VBA program, I'm currently using a RUNSQL statement with a "DELETE *
FROM MyTableName WHERE ColumnName=UserName".

Unfortunately, this gives a message to users like "Do you want to confirm to
delete X number of records?"

How can we get around / avoid this prompt for users?

Do I need to use DAO instead of SQL?

If yes, do you have a code example using DAO to find all the records then
delete them? The Find. Move Next. Delete syntax seems much more heavy & not
documented in the Access Help compared to the simplicity of SQL.
 
A

Allen Browne

Try executing the SQL string like this:
strSql = "DELETE FROM MyTableName WHERE ColumnName='UserName';"
dbEngine(0)(0).Execute strSql, dbFailOnError

This should give you no message, unless an error occurs (at which point it
aborts).
 
Top