MS Access SQL INSERT INTO VALUES: How-To
In this article
You can add a row to a Microsoft Access table with a single SQL statement: INSERT INTO TableName (Field1, Field2) VALUES ('Text', 123);. This works in Access queries and in VBA, and it is the fastest way to add one record or a handful of records without opening a form. Before you start, you need an existing table with the correct field names and data types. Access does not create tables from an INSERT statement, so the table must already exist.
What You'll Need
- Microsoft Access installed on your computer (desktop version). The web app has limited SQL support and cannot run INSERT statements.
- An existing table in your database. Note the exact field names and their data types (Short Text, Number, Date/Time, Yes/No, etc.).
- The database must be open in Access, and you should have permission to modify data. If the database is split, run the query against the back-end table.
- For date values, use the US format
#mm/dd/yyyy#or a format Access recognises, or use a parameter in VBA.
Step-by-Step
- Open your database and identify the table. In the Navigation Pane, find the table you want to add to. Double-click it to open it in Datasheet view and confirm the exact field names (for example
FirstName,LastName,HireDate). Field names with spaces must be wrapped in square brackets, like[First Name]. - Create a new query. Go to the Create tab on the ribbon and click Query Design. Close the Show Table dialog without adding any tables. Then switch to SQL view: on the Design tab, click View and choose SQL View (or use the View button drop-down).
- Write the INSERT statement. The basic pattern is:
INSERT INTO TableName (Field1, Field2, Field3) VALUES (Value1, Value2, Value3);For example:INSERT INTO Employees (FirstName, LastName, HireDate) VALUES ('Ana', 'Lopez', #3/15/2024#);Text values go in single quotes. Numbers have no quotes. Dates use the hash marks#. Yes/No fields acceptTrueorFalse(or -1 and 0). - Check the order of fields and values. The list of fields in parentheses must match the list of values in the same order. If you omit a field, Access will insert a blank (or the field's default value) for that field. If the field is required and has no default, the insert fails.
- Run the query. Click the Run button (the red exclamation mark) on the Design tab. Access may warn that you are about to append rows; click Yes. If the SQL is valid, you will see a message that you are about to append 1 row (or however many rows your statement affects).
- Verify the result. Open the table in Datasheet view and scroll to the bottom, or run a SELECT query to confirm the new record is there. If you used an AutoNumber primary key, Access fills it automatically.
- To insert multiple rows at once, use a separate INSERT statement for each row, separated by semicolons, or use a single INSERT with multiple VALUES groups if your Access version supports it (Access 2010 and later generally do not support multi-row VALUES in the query designer; use VBA or separate statements instead). In VBA, you can loop through a recordset or use
CurrentDb.Executewith one statement per row.
Labels in the Access ribbon can differ slightly by version and region, but the SQL syntax itself is stable across recent desktop versions.
Common Mistakes
- Missing quotes around text.
VALUES (Ana, Lopez)fails because Access treats unquoted words as field names or parameters. Use'Ana'and'Lopez'. - Wrong date format. Writing
'3/15/2024'as text into a Date/Time field can cause a type mismatch or store the wrong date depending on regional settings. Use#3/15/2024#or a parameter. - Field name with spaces not bracketed.
INSERT INTO Contacts (First Name) ...fails. Write[First Name]. - Mismatched number of fields and values. Access returns a syntax error if the counts differ.
- Inserting into an AutoNumber field. You normally should not include the AutoNumber field in the field list; Access assigns it. If you do include it, you must supply a unique number.
- Violating a validation rule or required field. The insert fails with a validation error. Check the table design for required fields and validation rules.
- Using the wrong table name. If the table name contains spaces, bracket it:
[Order Details].
Tips
- Test your INSERT on a copy of the table or a backup of the database first. An INSERT cannot be undone with Ctrl+Z once the query runs.
- Use the Query Designer's SQL view to format the statement across multiple lines for readability; Access ignores line breaks.
- For repeated inserts, consider a parameter query or VBA with
CurrentDb.Execute "INSERT INTO ..."so you can pass values safely without quoting issues. - If you need to insert from another table, use
INSERT INTO Target (Field1, Field2) SELECT Field1, Field2 FROM Source;rather than VALUES. - Always back up the database before running bulk INSERT statements.
Troubleshooting
If the query does not run, read the error message carefully. A "Syntax error in INSERT INTO statement" usually means a missing bracket, a missing quote, or a reserved word used as a field name (wrap reserved words in brackets). A "Data type mismatch" means a value does not match the field type: check that numbers are unquoted and dates use hash marks. A "Validation rule violation" means the value breaks a rule set in the table design; open the table in Design view and review the Validation Rule property. If you get "Field cannot be updated" or a permission error, the database may be read-only or the table may be linked without update permissions. If the query runs but the record does not appear, check that you are looking at the correct table and that you saved the query before running it. If you accidentally inserted wrong data, you can delete the row with a DELETE query that targets the specific record, but be careful: DELETE without a WHERE clause removes all rows.
Frequently Asked Questions
Can I insert multiple rows in one Access SQL statement?
Access desktop generally does not support the multi-row VALUES (...), (...) syntax. Use one INSERT statement per row, separated by semicolons, or loop in VBA.
Do I need to include every field in the INSERT statement?
No. You can list only the fields you want to fill. Access inserts blanks, zeros, or default values for the rest. However, required fields without defaults must be included.
How do I insert a date value?
Use hash marks around the date in US format, for example #12/31/2024#, or use a parameter in VBA to avoid regional format issues.
Can I use INSERT INTO with a linked table?
Yes, if the linked table is updatable and you have permission. The same syntax applies; just use the linked table name.
Why does Access ask me to confirm the append?
Access shows a warning before action queries that modify data. Click Yes to proceed. You can turn this warning off in the Access options, but it is safer to leave it on.
What if my field name is a reserved word like Date or Name?
Wrap it in square brackets: , . This prevents Access from misreading it as a keyword.