Follow us:

MS Access 2003: Suppress system messages (Query confirmations)

This MSAccess tutorial explains how to suppress system messages when running queries such as confirming deletions in Access 2003 (with screenshots and step-by-step instructions).

Question: In Microsoft Access 2003/XP/2000/97, how can I suppress the system messages when I run queries? For example, when a delete query is run, Access will ask you to confirm the number of deletions. How can I suppress these kinds of messages?

Answer: To suppress system messages in Access, you will need to use the "Docmd.SetWarnings" command. You could use the following code.

DoCmd.SetWarnings False

{ queries...}
DoCmd.SetWarnings True

For example, you could create a button on your form and place the following code on the Click event:

Private Sub Command1_Click()

   'Turn system messages off
   DoCmd.SetWarnings False
   DoCmd.OpenQuery "Delete all entries"
   DoCmd.OpenQuery "Populate with new entries"
   'Turn system messages back on
   DoCmd.SetWarnings True
End Sub

In this example, we have a button called Command1. When this button is clicked, the system messages will be turned off. Then two queries are run - one called "Delete all entries" and second query called "Populate with new entries".

After the two queries are run, the system messages are turned back on.

The purpose of turning off the system messages is to hide the following kinds of messages from the users:

Microsoft Access