What Does the Microsoft Access On Dirty Property Do? | WPS Support
Question details
The user wants to understand the function of the Dirty property and the On Dirty event in Microsoft Access, including how they track unsaved record edits and trigger programmatic actions.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Developing or managing bound forms where tracking unsaved changes is necessary to validate data or prompt users before saving.
- Observed behavior
- The user needs to trigger macros, expressions, or VBA procedures when a bound control is edited but before the record is saved to the underlying table.
Basic knowledge of Microsoft Access forms, bound controls, and VBA (Visual Basic for Applications) is recommended to effectively utilize the Dirty property and related events.
Understanding and Using the Dirty Property in VBA
Learn how the Dirty property tracks unsaved changes in a bound form and how to use it to save records.
The Dirty property acts as a flag that indicates whether the current record on a form has been modified but not yet committed to the database. A record is only committed when it is explicitly saved or when the user moves focus away from the record.
While the Dirty property is True, the underlying database table still contains the old data. The new data is held in memory until the save operation completes.
Observe that the Dirty property automatically becomes True the moment a user changes the value of a bound control, such as typing in a text box or selecting from a combo box.
To programmatically commit and save the modified record to the table, execute the VBA statement: Me.Dirty = False. This forces Access to save the changes immediately.

Configuring the On Dirty Event for Custom Actions
Set up the On Dirty event to run macros or VBA code immediately when editing begins on a record.
Looking for a Lightweight Alternative to Microsoft Office?
While Microsoft Access handles complex relational databases, most everyday data tracking, listing, and analysis can be managed effortlessly with WPS Spreadsheet. WPS Office is a free, lightweight, and highly compatible alternative to Microsoft Office, perfect for streamlining your daily data tasks without the steep learning curve.
- 1. Download and install: Visit the official WPS website to download the free WPS Office suite and complete the quick installation process.
- 2. Open WPS Spreadsheet: Launch WPS Office and click on 'Spreadsheet' to start managing your datasets, lists, and tables.
- 3. Import your data: Easily open your existing .xlsx or .csv files exported from databases to continue working seamlessly.

Frequently Asked Questions
What is the difference between the Dirty property and the On Dirty event?
The Dirty property is a boolean value (True or False) that tells you if the current record has unsaved modifications. The On Dirty event is the actual trigger that executes a macro or VBA procedure the exact moment the record becomes 'dirty' (when the first change is made).
How do I discard or undo changes if an Access form is dirty?
You can discard unsaved changes by using the VBA command Me.Undo. This will revert all edits on the current record to their original state and automatically reset the form's Dirty property back to False.
Why isn't the On Dirty event triggering on my form?
The On Dirty event will not trigger if the form is unbound or if the specific control being edited is unbound. It only fires when a user makes a change to a control that is directly bound to a field in the underlying table or query.




