Access: How to supress those "You are about to update..." warnings

M

Monty

I have an updated query attached to the "on close" event of a form in Access.
But now, before Access allows me to close the form, I get a warning that the
query is about to run and that "x" number of records will be changed.

How do I turn off this irritating warning/
 
D

Dirk Goldgar

Monty said:
I have an updated query attached to the "on close" event of a form in
Access. But now, before Access allows me to close the form, I get a
warning that the query is about to run and that "x" number of records
will be changed.

How do I turn off this irritating warning/

Does your form use DoCmd.RunSQL or DoCmd.OpenQuery to run the query? If
so, you can replace that line with one like this:

CurrentDb.Execute "YourQueryNameOrSQL", dbFailOnError

The only problem with that would be if you query uses a reference to a
control on a form. In that case, the above won't work, and you would do
better to use code like this:

Private Sub Form_Close()

On Error GoTo Err_Handler

DoCmd.SetWarnings False
DoCmd.OpenQuery "YourQueryName"

Exit_Point:
DoCmd.SetWarnings True
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
Resume Exit_Point

End Sub
 
O

Ofer

Put the code
docmd.SetWarnings false
before running the query, that will turn off this irritating warning
and after running the query change it back to true
docmd.SetWarnings True
 
Top