Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

MS Access INSERT INTO SQL: Step-by-Step Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To insert rows into an Access table with SQL, use the INSERT INTO statement in a query: INSERT INTO TableName (Field1, Field2) VALUES ('Text', 123);. You can run it from the SQL View of a query, from VBA with CurrentDb.Execute, or from an external tool that connects through the Access database engine. The statement writes one row at a time unless you use a multi-row form or an INSERT INTO ... SELECT that copies from another table.

What You'll Need

  • Microsoft Access installed (any recent desktop version) and the database file open.
  • The exact table and field names. Access is forgiving about some things but not about misspelled names.
  • Permission to modify data in the database. If the file is read-only or on a locked network share, writes fail.
  • For external connections: the Microsoft Access Database Engine (ACE) provider installed on the machine making the connection.

Step-by-Step

  1. Open the database and confirm the target table. In the Navigation Pane, find the table you want to write to. Double-click it to open it in Datasheet View and note the exact field names in the column headers. Field names with spaces must be wrapped in square brackets, for example [First Name].
  2. Create a new query in SQL View. Go to Create > Query Design, close the Show Table dialog without adding anything, then switch to SQL View using the button in the ribbon (or right-click the query tab and choose SQL View). The exact label can differ slightly by Access version, but the SQL View option is always on the query design ribbon.
  3. Write the INSERT statement. The basic pattern is:
    INSERT INTO Customers (FirstName, LastName, Age) VALUES ('Ana', 'Lopez', 34);
    List the fields in the same order as the values. Text values go in single quotes; numbers and dates do not. Dates use the US format #mm/dd/yyyy# in Access SQL, for example #12/31/2025#. If a field is an AutoNumber, leave it out of the field list entirely.
  4. Run the query. Click Run (the red exclamation mark). Access will warn that you are about to append rows; confirm. If the statement is valid, you see no result grid, just a message that rows are being appended. Switch back to the table in Datasheet View and refresh to see the new row.
  5. Insert multiple rows. Access SQL does not support the VALUES (...), (...) multi-row syntax used by SQL Server and MySQL. To add several rows, either run separate INSERT statements, or use INSERT INTO Target (Field1, Field2) SELECT Field1, Field2 FROM Source; to copy rows from another table or query in one go.
  6. Insert from VBA (optional). In the Visual Basic Editor, use CurrentDb.Execute "INSERT INTO ...", dbFailOnError. The dbFailOnError argument makes Access raise an error if the insert fails, which is much easier to debug than a silent failure. Wrap the call in error handling if the statement runs from a form button.
  7. Insert from an external application (optional). From PowerShell, a .NET application, or a script, connect using the ACE OLEDB provider (for example Microsoft.ACE.OLEDB.12.0) and run the same INSERT statement through a command object. The database file must not be open exclusively in Access at the same time.

Common Mistakes

  • Mismatched field and value counts. If you list three fields, you must supply exactly three values. Access reports a syntax error rather than telling you which side is wrong.
  • Forgetting quotes around text. VALUES (Ana) is read as a field or parameter name, not a string. Use VALUES ('Ana').
  • Using the wrong date format. Access SQL expects #mm/dd/yyyy# regardless of your Windows regional date settings. A date typed as #31/12/2025# can be misread or rejected.
  • Including the AutoNumber field. Supplying a value for an AutoNumber column causes an error unless you explicitly enable it, which is rarely what you want.
  • Reserved words as field names. Names like Date, Value, Password or Order must be wrapped in square brackets, or Access misreads the statement.
  • Violating a validation rule or required field. If a field is required and has no default, or a validation rule rejects the value, the whole row is rejected. Check the table design if inserts fail for no obvious reason.

Tips

  • Test the SELECT version of your statement first: SELECT 'Ana' AS FirstName, 'Lopez' AS LastName; confirms your quoting and date literals before you write anything.
  • Use a parameter query or VBA parameters instead of concatenating user input into SQL. This avoids quote-escaping problems and is safer when values come from a form.
  • If you need to insert many rows, wrap the operation in a transaction in VBA (BeginTrans / CommitTrans) so a failure partway through does not leave half the data behind.
  • Keep a copy of the table or a backup of the database before running bulk INSERT ... SELECT statements. There is no undo once the rows are appended.
  • For repeated imports, link the external data as a table and use an append query in the query designer rather than hand-writing SQL each time.

Troubleshooting

If Access shows a syntax error, check the field list and value list first, then confirm every text value has single quotes and every date uses #...#. If the error mentions a missing parameter, a name in the statement does not match a field or is being read as a variable. If you get a key violation, the value you are inserting already exists in a primary key or unique index; change the value or remove the field from the insert. If the operation is rejected because the record is locked, close other users' open forms or wait and retry. If an external connection fails, confirm the ACE provider is installed and that the file path in the connection string is correct. If the statement runs but no row appears, check that you refreshed the table and that you are looking at the same database file, not a copy.

Frequently Asked Questions

Can I insert multiple rows in one Access SQL statement?

Not with the multi-row VALUES syntax. Use separate INSERT statements or INSERT INTO ... SELECT to copy several rows at once.

Why does my date value cause an error?

Access SQL expects dates in #mm/dd/yyyy# format. Reformat the literal and try again.

Do I need to include every field in the INSERT statement?

No. List only the fields you are supplying. Fields you omit must allow nulls or have a default value.

Can I insert into a linked table?

Yes, provided the linked source accepts the data types and constraints. The same INSERT syntax applies, but errors may come from the back-end database rather than Access.

How do I insert the current date automatically?

Use the Date() function in the VALUES list, for example VALUES (Date()), or set a default value of Date() in the table design.

What is the difference between INSERT INTO and an append query?

They are the same operation. An append query is the query designer's visual way of building an INSERT INTO statement.