Once you start doing some VBA programming in your database you will at some point or another want to run/execute queries through VBA. However, you may not want your user’s to receive the action query confirmation prompts, such as:

Nothing could be easier. To disable all confirmation prompts simply use the following line of code
DoCmd.SetWarnings False 'Turn off warnings
Of course do not forget to turn them back on after running your code so that legitimate messages are displayed.
DoCmd.SetWarnings True 'Turn warnings back on
Require a code or procedure with the help of which I’ll avoid this warning message.
I’m trying to send email automatically via VBA and need this meesage box to be supressed
I think you are confusing the Query Warning with the Outlook warning, see: http://www.devhut.net/2013/03/26/ms-access-bypassing-the-e-mail-security-warning/
Where I should put that code?? and how can I use it??
You would build your VBA procedure something along the lines of:
DoCmd.SetWarnings False ‘Turn off warnings
‘Run the rest of your code
DoCmd.SetWarnings True ‘Turn warnings back on
So something like:
DoCmd.SetWarnings False ‘Turn off warnings
CurrentDB.Execute “YourQueryName”, dbFailOnError ‘Assuming YourQueryName is an action query
DoCmd.SetWarnings True ‘Turn warnings back on
Also, always ensure the
DoCmd.SetWarnings True ‘Turn warnings back on
is part of your error handling routine to ensure error reporting is reactivated in the case of an error in your procedure! So the end result could be something along the lines of:
Sub YourProcedureName()
On Error GoTo Error_Handler
DoCmd.SetWarnings False ‘Turn off warnings
CurrentDb.Execute “YourQueryName”, dbFailOnError ‘Assuming YourQueryName is an action query
Error_Handler_Exit:
On Error Resume Next
DoCmd.SetWarnings True ‘Turn warnings back on
Exit Sub
Error_Handler:
MsgBox “The following error has occured.” & vbCrLf & vbCrLf & _
“Error Number: ” & Err.Number & vbCrLf & _
“Error Source: YourProcedureName” & vbCrLf & _
“Error Description: ” & Err.Description, _
vbCritical, “An Error has Occured!”
Resume Error_Handler_Exit
End Sub