Suppress Access Messages

G

Guest

Hi,

Can anybody help me, i have a couple of queries that are run on the "On Open" event of a form, these queries modify or delete data in a table. Everytime the form is opened i get the followong message "You are about to run a delete query that will modify data in your table".

I know that in the options menu under the Edit/Find tab you can deselect the "Record Changes", and "Action Queries" tick boxes to get rid of these messages. But is there a way of coding in to the forms' "On Open" event something to supress the messages just for these particullar queries.

I know that in excell there is asimilar command "Application.DisplayAlerts" which when set to false does ot display any warning or error pop ups. Is there anything for access? I am running Access 2002.

Thank you in advance for any any help you may be able to provide.
 
N

Nikos Yannacopoulos

Shabbir,

Yes, there is, it's DoCmd.SetWarnings. Use one with argument False before
the action queries in your code, and one more with argument True right
after.

HTH,
Nikos

Shabbir said:
Hi,

Can anybody help me, i have a couple of queries that are run on the "On
Open" event of a form, these queries modify or delete data in a table.
Everytime the form is opened i get the followong message "You are about to
run a delete query that will modify data in your table".
I know that in the options menu under the Edit/Find tab you can deselect
the "Record Changes", and "Action Queries" tick boxes to get rid of these
messages. But is there a way of coding in to the forms' "On Open" event
something to supress the messages just for these particullar queries.
I know that in excell there is asimilar command
"Application.DisplayAlerts" which when set to false does ot display any
warning or error pop ups. Is there anything for access? I am running Access
2002.
 
G

Glenn

Just before the code that runs the queries insert

DoCmd.SetWarnings False

The after set the warnings back on:

DoCmd.SetWarnings true

Rgds,
Glenn.

-----Original Message-----
Hi,

Can anybody help me, i have a couple of queries that are
run on the "On Open" event of a form, these queries modify
or delete data in a table. Everytime the form is opened i
get the followong message "You are about to run a delete
query that will modify data in your table".
I know that in the options menu under the Edit/Find tab
you can deselect the "Record Changes", and "Action
Queries" tick boxes to get rid of these messages. But is
there a way of coding in to the forms' "On Open" event
something to supress the messages just for these
particullar queries.
I know that in excell there is asimilar
command "Application.DisplayAlerts" which when set to
false does ot display any warning or error pop ups. Is
there anything for access? I am running Access 2002.
 
C

Craig Smith

Shabbir,

The suggestion below is correct, however if there is a
problem with your program / code, and the sub or function
ends prematurely, the warnings will remain switched off
which can lead to some inadvertant deletion of tables and
other important things :).

Regards,
Craig
 
G

Graham R Seach

Shabbir,

You are probably using DoCmd.RunSQL to execute the queries. To use them
without displaying the messages, you need to use DoCmd.SetWarnings. But as
Craig has correctly warned, if something goes wrong, you'll be stuck with no
warnings at all.

The solution is to change from using DoCmd.RunSQL to using db.Execute. There
are no warnings with db.Execute, and you can trap errors on it too:
db.Execute dbFailOnError

db must be a valid database object, which means it can be DBEngine(0)(0) or
a derivative, CurrentDb, or an object variable.
DBEngine(0)(0).Execute strSQL, dbFailOnError
CurrentDb.Execute strSQL, dbFailOnError

Set db = CurrentDb
db.Execute strSQL, dbFailOnError

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Shabbir said:
Hi,

Can anybody help me, i have a couple of queries that are run on the "On
Open" event of a form, these queries modify or delete data in a table.
Everytime the form is opened i get the followong message "You are about to
run a delete query that will modify data in your table".
I know that in the options menu under the Edit/Find tab you can deselect
the "Record Changes", and "Action Queries" tick boxes to get rid of these
messages. But is there a way of coding in to the forms' "On Open" event
something to supress the messages just for these particullar queries.
I know that in excell there is asimilar command
"Application.DisplayAlerts" which when set to false does ot display any
warning or error pop ups. Is there anything for access? I am running Access
2002.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top