Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove confirmation when using DoCmd.RunSQL for INSERT and DELETE

Tags:

sql

vba

ms-access

I am using the DoCmd.RunSQL method to INSERT and DELETE records based on actions that a user makes in a form. It works fine but it asks for a confirmation before deleting or appending a record. How can I remove the confirmation.

By the way, the BeforeDelConfirm event doesn't seem to run with DoCmd.RunSQL.

like image 218
jaromey Avatar asked May 30 '13 13:05

jaromey


1 Answers

Rather than using DoCmd.RunSql to run your SQL and worrying about alerts you can use this.

Dim sql as string
Dim dbs as DAO.Database
set dbs = CurrentDb()

sql = "INSERT INTO table(field1) VALUES(1)"
dbs.Execute sql, dbFailOnError

dbs.close
set dbs = nothing
like image 117
Zaider Avatar answered Nov 09 '22 10:11

Zaider