Acknowledging row deletion message

W

Wylie C

I have an SQL statement that deletes rows from a table. When the close form
code runs the user is asked for confirmation of deletions. I would like the
rows to be deleted without prompting the user for a response. My code
currently is:

Private Sub Close_Click()
strSql = "Delete rows from Routes where [Short Description] is null"
On Error GoTo Err_Close_Click


DoCmd.Close
DoCmd.RunSQL strSql


Exit_Close_Click:
Exit Sub

Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click

End Sub

Thank you.
 
P

PC Datasheet

Put the following before and after your RunSQL code:
DoCmd.SetWarnings False
DoCmd.RunSQL strSql
DoCmd.SetWarnings True

Is your Sub running okay? Usuallly you will get an error when you try and
execute code after DoCmd.Close code. It would be better if you move your
DoCmd.Close after DoCmd.SetWarnings True.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top