Ben said:
I have a command button that inserts data into a table and it works great.
I want to have that command button also have it automatically click Yes
when
it prompts the user "You are about to append 1 row...". How can I do
that?
What's the code?
You could have code like this:
'------ start of example code #1 -----
Private Sub cmdInsert_Click()
CurrentDb.Execute "INSERT INTO ...", dbFailOnError
End Sub
'------ end of example code #1 -----
or else you could use code like this:
'------ start of example code #2 -----
Private Sub cmdInsert_Click()
On Error GoTo Err_Handler
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO ..."
Exit_Point:
DoCmd.SetWarnings True
Exit Sub
Err_Handler:
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
Resume Exit_Point
End Sub
'------ end of example code #2 -----
The second example is more involved than the first, because it's very
important that you not let the procedure complete without turning the
warnings back on.