Others

Delete Access Records with Null Values Using VBA

Camila MilosovichCamila Milosovich Nov 25, 2026 869 views

Question details

Delete all Access table records where a specified field is Null when a form loads.

Delete Access Records with Null Values Using VBA
Product
Microsoft Access
Device & OS
not provided
Scenario
An Access form should run a deletion query automatically during its Load event.
Observed behavior
When the form loads, records with a Null value in the chosen field should be deleted.
Before you start

Identify the table and field to check, and confirm that deleting the matching records is intended every time the form loads. Run a SELECT query with the same Is Null condition first to review which records will be affected.

Solution 1Recommended

Run a DELETE query in the Access form's Load event

Use the form's Load event to delete matching records whenever the form opens.

1
Open the form in Design View

In the Navigation Pane, right-click the form and select Design View. Open the Property Sheet and select the form.

2
Create the Load event procedure

On the Property Sheet's Event tab, select On Load, choose [Event Procedure], and click the ellipsis button to open the VBA editor.

3
Add the DELETE statement

Inside the Form_Load procedure, enter: CurrentDb.Execute "DELETE FROM [tablename] WHERE [fieldname] Is Null;", dbFailOnError. Replace tablename and fieldname with the actual table and field names.

4
Save and test the form

Save the form, open it in Form View, and inspect the table to verify that only the intended records were deleted.

Run a DELETE query in the Access form's Load event
Deletion occurs on each load: The query deletes entire records, not just field values. dbFailOnError reports an error if the action query cannot complete.
Free Microsoft Office alternative

Work with Office documents using WPS Office

WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility for an easier migration. It does not run Access VBA or replace Access for managing its databases.

Review and organize exported table data in WPS SpreadsheetsOpen and edit Microsoft Excel, Word, and PowerPoint formats, including XLSX, DOCX, and PPTXUse a familiar interface for everyday document and spreadsheet workWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

How can I preview the records before deleting them?

In Access, create a query in SQL View and run SELECT * FROM [tablename] WHERE [fieldname] Is Null; after replacing the table and field names.

Does Is Null also find empty strings?

No. Is Null finds Null values, not zero-length strings. For a text field, use a condition such as [fieldname] Is Null OR [fieldname] = '' if both should be included.

Why does the delete query report an error?

Check the table and field names, deletion permissions, and any relationships that prevent deleting the records. The dbFailOnError option causes Access to report an error when the action query cannot complete.

Can WPS Office run the Access form's VBA code?

No. Run the form and its VBA Load event in Microsoft Access. You can export table data to an Excel-compatible file and open it in WPS Spreadsheets for review.