Turn off Delete Table confirmation box??? (1 Viewer)

smpayne

Registered User.
Local time
Today, 15:16
Joined
Sep 29, 2004
Messages
27
I have created a query that deletes and replaces tables, but I do not want the Delete Confirmation message to pop up all the time, how do I turn it off?? I know there are options in the Edit section to turn off 3 other confirmations, but not the delete. I want the macro to run silent without user intervention.

Hope someone can help!!

Shawn.
 

Simplycongy

Registered User.
Local time
Today, 23:16
Joined
Nov 8, 2004
Messages
43
Hey

You can disable most user warnings with the following command

DoCmd.SetWarnings False

But remember to turn them back on with before the end of your code

DoCmd.SetWarnings True

Or you might delete things accidentally!!!
 

adaytay

Not your typical IT Geek!
Local time
Today, 23:16
Joined
May 14, 2004
Messages
16
Hiya,

You don't specify how the query is being run - via a macro or a VB module.

If it's a macro, you can setwarnings to false, run the query and then setwarnings to True again (essential step!).

If it's via a VB module, something like this will do:
Code:
DoCmd.SetWarnings False
DoCmd.OpenQuery [b][i]YourQueryName[/i][/b]
DoCmd.SetWarnings True
HTH,

Ad
 

smpayne

Registered User.
Local time
Today, 15:16
Joined
Sep 29, 2004
Messages
27
Thank you!

I didn't even see the SetWarnings command in the macro editor. Thanks man, you saved me a huge headache!

Shawn
 

Mile-O

Back once again...
Local time
Today, 23:16
Joined
Dec 10, 2002
Messages
11,316
To save duplicating the same code all over the place for using different action queries I use this little function.

Code:
Public Function RunQuery(ByVal QueryName As String) As Boolean
    On Error Goto Err_RunQuery
    With DoCmd
        .SetWarnings False
        .OpenQuery QueryName
        .SetWarnings True
    End With
    RunQuery = True
    Exit Function
Err_RunQuery:
    RunQuery = False
End Function

This gives you the option of actually checking if the query was run successfully too.

i.e.

Code:
If RunQuery("qryDeleteRecords") = True Then
    MsgBox "Delete was successful", vbInformation
Else
    MsgBox "Delete was not successful", vbExclamation
End If
 

Users who are viewing this thread

Top Bottom