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
Reply to group, rather than allenbrowne at mvps dot org.
Laurel said:
Thanks! Will be careful.
Jeff Boyce said:
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
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