What is it?
Why is it?
You can avoid the process of opening the DB and executing the query manually; this code will execute even from an Excel sheet without opening the Access DB manually.
How to use VBA code to Execute Access Query
Step 1: Copy Paste the below code in your module.
Dim myDB As Database
Set myDB = OpenDatabase(“C:\MYDATABASE.mdb”) ‘Mention the DB path and Replace the ‘MYDATABASE’ with your Access DB name
myDB.Execute “myQuery” ‘Replace ‘myQuery with your Access Query name
myDB.close ‘Use this only if you want to close DB
Step 2: Click the Run button or F5 to Execute the Access Query.