Re: Suppress "You are about to delete... " message?



Laurel, an alternative approach is to use Execute rather than RunSQL:
ls_sql = "DELETE from tblAcademics WHERE [student_id] = " _
& rstClassList![Student_ID]
dbEngine(0)(0).Execute ls_sql, dbFailOnError

Advantages:
1. You don't need to turn setwarnings off.
2. It *does* give you a warning if the delete fails.

Details in:
Action queries: suppressing dialogs, while knowing results
at:
http://allenbrowne.com/ser-60.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Laurel" <FakeMail@xxxxxxxxxxx> wrote in message
news:OZuvWUcxHHA.1208@xxxxxxxxxxxxxxxxxxxxxxx
Thanks! Will be careful.

"Jeff Boyce" <nonsense@xxxxxxxxxxxx> wrote in message news:esC4MiXxHHA.536@xxxxxxxxxxxxxxxxxxxxxxx
Laurel

You can turn off the warning(s) Access gives.

NOTE -- IF YOU FAIL TO TURN THE WARNINGS BACK ON, YOU WILL NEVER KNOW WHEN ACCESS IS FAILING!

I'd recommend something like:

DoCmd.SetWarnings False
DoCmd.RunSQL ls_sql

DoCmd.SetWarnings True

AND I'd suggest adding

DoCmd.SetWarnings True

in your 'exit' routine, plus ensure that even an error condition exits via your exit routine, ensuring that the warnings get turned back on no matter what happens.

(and I also created a simple macro to turn warnings back on if, despite my every effort, they still manage to get turned off)

Regards

Jeff Boyce
Microsoft Office/Access MVP


"Laurel" <FakeMail@xxxxxxxxxxx> wrote in message news:%23%2351scXxHHA.1776@xxxxxxxxxxxxxxxxxxxxxxx
I have several lines of code that look like this. Is there some way I can suppress the message, "You are about to delete x row(s) from the specified table." etc.,,, Yes, No.

ls_sql = "DELETE from tblAcademics WHERE [student_id] = " _
& rstClassList![Student_ID]
DoCmd.RunSQL ls_sql

.



Relevant Pages

  • Re: Suppress "You are about to delete... " message?
    ... NOTE -- IF YOU FAIL TO TURN THE WARNINGS BACK ON, ... ACCESS IS FAILING! ... in your 'exit' routine, plus ensure that even an error condition exits via ... your exit routine, ensuring that the warnings get turned back on no matter ...
    (microsoft.public.access.formscoding)
  • Re: Suppress "You are about to delete... " message?
    ... NOTE -- IF YOU FAIL TO TURN THE WARNINGS BACK ON, ... ACCESS IS FAILING! ... in your 'exit' routine, plus ensure that even an error condition exits via ... your exit routine, ensuring that the warnings get turned back on no matter ...
    (microsoft.public.access.formscoding)
  • Re: Suppress "You are about to delete... " message?
    ... It *does* give you a warning if the delete fails. ... NOTE -- IF YOU FAIL TO TURN THE WARNINGS BACK ON, ... via your exit routine, ensuring that the warnings get turned back on no ...
    (microsoft.public.access.formscoding)
  • Re: Problem with Win32::Console and END block.
    ... > use strict; ... > use warnings; ... select STDOUT; ...
    (comp.lang.perl.misc)
  • Re: a way to make this more secured and better written?
    ... > use warnings; ... > use CGI(); ... > sub check_fields { ... Single quotes mean no interpolation which is a bir faster, aslo not exit ...
    (perl.beginners)