There are a number of ways to save data via an Access form. The easiest way is to let a bound form take care of it. However, sometimes even a bound form loses data, unexpectedly. For instance, if a user forgets to press Enter after changing or entering a value and code takes over, VBA won’t consider that unsaved value in any processing. In addition, some developers like to bypass the bound behaviors and control the save process using code. Either way, the Dirty property is usually the most efficient way to save the current record.

The Dirty property applies to both the Form and Report objects. When a user changes a record but hasn’t saved it, the Dirty property returns True — the object is dirty.  When the record hasn’t been changed, Dirty returns False. This Boolean structure makes it easy to save a record quickly — or not — as needed. Simply drop the following statement into code:

If Me.Dirty Then Me.Dirty = False

Setting the object’s Dirty property to False forces Access to save the current record. If the object isn’t dirty, the statement does nothing.