Others

Copy and Clean Array Data into a Microsoft Access Table

Muhammad TalhaMuhammad Talha Nov 27, 2026 868 views

Question details

Copy cleaned array values into corresponding fields in an Access table, or use a query where appropriate.

Copy and Clean Array Data into a Microsoft Access Table
Product
Microsoft Access
Device & OS
not provided
Scenario
A user edits values in an array and needs to write the results to a destination table.
Observed behavior
Access does not provide a PutRow method for writing an array directly to a table; values must be assigned to fields or processed with a query.
Before you start

Identify the source and destination fields, their data types, and any required destination fields. The examples use text fields named FirstName and LastName in tables named SourceTable and DestinationTable; replace them with your actual names.

Solution 1Recommended

Write cleaned array values with a DAO Recordset

Use this approach when your cleaning logic already works on an array or requires record-by-record processing.

Access has no PutRow method for this task. Open the destination Recordset once, then use AddNew, assign each array element to its destination field, and call Update for each source record.

1
Open a VBA module

In Access, press Alt+F11, then select Insert > Module in the VBA editor.

2
Add the copy procedure

Paste this example into the module and replace the table and field names as needed: Public Sub CopyCleanedRows() Dim db As DAO.Database Dim src As DAO.Recordset Dim dst As DAO.Recordset Dim values As Variant Set db = CurrentDb Set src = db.OpenRecordset("SourceTable", dbOpenSnapshot) Set dst = db.OpenRecordset("DestinationTable", dbOpenDynaset) Do While Not src.EOF values = Array(Trim(Nz(src!FirstName, "")), Trim(Nz(src!LastName, ""))) dst.AddNew dst!FirstName = values(0) dst!LastName = values(1) dst.Update src.MoveNext Loop src.Close dst.Close Set src = Nothing Set dst = Nothing Set db = Nothing End Sub

3
Run and check the results

Place the cursor inside CopyCleanedRows and press F5. Open DestinationTable in Access and verify that the new records and cleaned values are correct.

Write cleaned array values with a DAO Recordset
Adapt the field assignments: The example trims text and replaces Null values with empty strings. Add assignments for required fields and use cleaning rules that match your data types. Running the procedure again appends the records again.
Free Microsoft Office alternative

Work with spreadsheet data in WPS Office

WPS Office is a free, lightweight alternative for working with office documents and spreadsheets in a familiar interface. Its format compatibility can make migrating spreadsheet work easier, though it does not replace Microsoft Access or run Access queries and VBA procedures.

Review and organize tabular data in WPS SpreadsheetOpen and edit Microsoft Excel XLSX filesWork with common Microsoft Word and PowerPoint formatsUse a familiar interface for everyday office tasks
QA img-9

Frequently Asked Questions

Can Access write an entire array to a table with PutRow?

No. For a DAO Recordset, call AddNew, assign each array element to its matching field, and call Update for each new record.

Is an append query faster than looping through an array?

An append query is usually faster and more scalable for large datasets when the cleaning can be expressed in SQL. Create one through Create > Query Design and switch to SQL View.

How do I update existing records instead of adding new ones?

Use an update query with criteria that identify the records to change. An append query or Recordset AddNew adds new records instead.

What happens if a source value is Null?

In the examples, Nz(value, '') replaces Null with an empty string before Trim removes surrounding spaces. Adjust that rule if the destination should retain Null values.