JudithARyan
asked on
DoCmd.SetWarnings False is not working
I need to suppress the "you are about to delete 1 row(s)" error message. I am using a MsgBox to verify which DELETE is being executed. And I'm still getting the error message. I've used this method before, why isn't it working now? I'm using Access 2013.
If UserID = -1 Then
DoCmd.SetWarnings False
DoCmd.RunSQL ("DELETE * FROM SysUsers WHERE WSID = '" & GetWSID() & "'")
MsgBox ("UserID = " & UserID)
DoCmd.SetWarnings True
Judith
If UserID = -1 Then
DoCmd.SetWarnings False
DoCmd.RunSQL ("DELETE * FROM SysUsers WHERE WSID = '" & GetWSID() & "'")
MsgBox ("UserID = " & UserID)
DoCmd.SetWarnings True
Judith
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm really concerned about having to change these SetWarning statements, since I have them throughout my app. When I did a right click on False and selected Definition, I got the message that "Identifier under cursor is not recognized" !!!!!
I'll have to do a Find throughout my app to see if I've used False inappropriately. I don't think I have, but I need to check it.
Is there a way to turn off global variables like False in some other way?
Judith
I'll have to do a Find throughout my app to see if I've used False inappropriately. I don't think I have, but I need to check it.
Is there a way to turn off global variables like False in some other way?
Judith
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
create a copy of your db
in the copy, vba window hit CTRL + F
in the Find What box, place DoCmd.SetWarnings
select the Search Option Current Project
click Replace
in replace With box, place 'DoCmd.SetWarnings
click OK
that will comment all your DoCmd.SetWarnings
now go back to the codes you posted above and un-comment the two DoCmd.SetWarnings
test your code
in the copy, vba window hit CTRL + F
in the Find What box, place DoCmd.SetWarnings
select the Search Option Current Project
click Replace
in replace With box, place 'DoCmd.SetWarnings
click OK
that will comment all your DoCmd.SetWarnings
now go back to the codes you posted above and un-comment the two DoCmd.SetWarnings
test your code
"I'm really concerned about having to change these SetWarning statements,"
Like I suggested yesterday ... you should really get away from using the dangerous SetWarnings statements.
Like I suggested yesterday ... you should really get away from using the dangerous SetWarnings statements.
Setting warnings off is so dangerous that i created a macro to do it. In the macro, I set the hourglass on and the warnings off. The on macro sets the warnings on and the hourglass off. This way I always have a visual clue when the warnings are off. Replacing your set statements with the macro will be a smaller change than changing to use the .execute method but I agree with Joe that the .execute is safer but creating the macro is easier to implement for old stuff.
ASKER
Rey, I finally conceded and changed my SQL statements to Currentdb.Execute and I'm not getting errors. Thanks for that!
Anders, If you hadn't mentioned going back in my code to see if the error was coming for something further back, I wouldn't have known which SQL statements to change! Thanks to you too!
Experts Exchange is the best, what would I do without you guys!!!
Judith
Anders, If you hadn't mentioned going back in my code to see if the error was coming for something further back, I wouldn't have known which SQL statements to change! Thanks to you too!
Experts Exchange is the best, what would I do without you guys!!!
Judith
Like I said ....
Try rightclicking your the False variable, and select "Definition"