But it also hides errors you may not be expecting.įor example, when you execute an INSERT INTO via the. Turning off the warnings hides the confirmation messages and the action canceled errors. The problem with this approach is that it's all or nothing. Simply turn the warnings off, execute the RunSQL method, then turn the warnings back on. To avoid these prompts, a quick Google search will likely lead you to the most expedient solution: the DoCmd.SetWarnings method. If the user clicks, Access will raise a runtime error: If the user clicks, the Delete query will execute and the records will be removed from the table. When you call DoCmd.RunSQL, Microsoft Access is going to show a confirmation window before executing the query. Dim Db As DAO.Databaseĭb.Execute "DELETE * FROM MyTable", dbFailOnErrorĭebug.Print Db.RecordsAffected What's Wrong With DoCmd.RunSQL? CurrentDb.Execute "DELETE * FROM MyTable", dbFailOnError
0 Comments
Leave a Reply. |