logo
search
VBA & Macro Problems

Fix Microsoft Access Crashing When VBA Appends Multiple Records

John WilsonJohn Wilson Oct 7, 2026 869 views

Question details

Microsoft Access crashes when attempting to use a VBA routine to append approximately 23 records to a linked table or Microsoft Teams Dataverse source.

How to Fix Microsoft Access Crashing When VBA Appends Multiple Records
Product
Microsoft Access
Device & OS
not provided
Scenario
Using a VBA script with a recordset loop to bulk upload multiple rows of data into a remote linked table or Dataverse environment.
Observed behavior
Appending a single record works fine, but uploading multiple rows causes the Access application to crash completely. Attempting to fix the delay using Sleep, Wait, or DoEvents does not resolve the data-integrity or remote commitment failures.
Before you start

Before modifying your VBA code or performing database maintenance, always create a secure backup copy of your Microsoft Access database file to prevent accidental data corruption or loss.

Solution 1Recommended

Use an INSERT SQL Statement Instead of Looping Recordsets

Executing bulk SQL commands is more stable and efficient than modifying linked recordsets row-by-row, which can overwhelm the connection to Dataverse and cause Access to crash.

Instead of using DAO or ADO recordset loops with .AddNew and .Update, sending a direct INSERT INTO SQL command handles the data transfer efficiently at the database engine level. This drastically reduces network chatter and prevents the application from hanging or crashing while waiting for remote commitment confirmations.

1
Open the VBA Editor

Press ALT + F11 within Microsoft Access to open the Visual Basic for Applications (VBA) editor window.

2
Locate the problematic loop

Find the module containing your append routine. Identify the loop where you are using recordset manipulation to add new rows.

3
Replace with an SQL execution command

Comment out the recordset loop and replace it with an SQL command. Use the format: CurrentDb.Execute "INSERT INTO TargetTable (Field1) VALUES ('Value1')", dbFailOnError.

Use an INSERT SQL Statement Instead of Looping Recordsets
Utilize dbFailOnError: Adding the dbFailOnError parameter ensures that if a record fails to insert, the operation halts and rolls back cleanly, generating a trappable error instead of crashing the entire Access application.
Free Microsoft Office alternative

Looking for a Lightweight, Crash-Free Office Suite?

While WPS Office does not directly replace Microsoft Access database functionality, it offers a fast, highly compatible, and lightweight alternative for your daily word processing, spreadsheet, and presentation needs. If you're experiencing frequent Office suite crashes or sluggish performance, consider WPS Office as a stable, free companion for managing and analyzing your exported database data.

  1. 1. Download the software: Visit the official WPS Office website and download the free installation package for your operating system.
  2. 2. Install WPS Office: Run the installer and follow the quick setup wizard to install the lightweight suite on your computer.
  3. 3. Open exported database files: Export your Access tables to .xlsx or .csv, then open them seamlessly in WPS Spreadsheet to filter, analyze, and chart your data without crashing.
Fully compatible with Microsoft Excel (.xlsx), Word (.docx), and PowerPoint (.pptx) formats.Lightweight installation with significantly lower system resource usage, preventing arbitrary crashes.Familiar tabbed user interface, ensuring zero learning curve when migrating from MS Office.Built-in robust PDF editor and advanced spreadsheet data analysis tools for managing your exported reports.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Access crash instead of throwing a standard VBA error when appending records?

Access can crash entirely if the network connection to a linked table (like Dataverse) times out, or if corrupted compiled VBA code (p-code) causes memory leaks during rapid processing loops. Shifting from recordset loops to bulk SQL execution usually resolves this instability.

Will adding a 'Sleep' or 'Wait' command fix the data append crash?

No. Adding arbitrary delays like Sleep, Wait, or DoEvents does not reliably confirm that the remote data has been committed. These commands often just mask the underlying network concurrency or data-integrity issues rather than solving them.

How do I fix a corrupted Access database that keeps crashing my VBA routines?

First, create a backup copy of your database. Next, use the /decompile command-line switch to strip out corrupted compiled code. Once decompiled, open the VBA editor, select 'Compile' from the Debug menu, and finally use the built-in 'Compact and Repair' utility.