You can use the Dirty property to determine whether the current record has been modified since it was last saved. For example, you may want to ask the user whether changes to a record were intended and, if not, allow the user to move to the next record without saving the changes. Read/write Boolean.
expression Required. An expression that returns one of the objects in the Applies To list.
The Dirty property uses the following settings.
||The current record has been changed.
||The current record has not been changed.
This property is available in Form view (Form view: A view that displays a form to show or accept data. Form view is the primary means of adding and modifying data in tables. You can also change the design of a form in this view.) and Datasheet view (Datasheet view: A view that displays data from a table, form, query, view, or stored procedure in a row-and-column format. In Datasheet view, you can edit fields, add and delete data, and search for data.).
This property set or read using a macro (macro: An action or set of actions that you can use to automate tasks.) or Visual Basic for Applications (VBA) (Visual Basic for Applications (VBA): A macro-language version of Microsoft Visual Basic that is used to program Microsoft Windows-based applications and is included with several Microsoft programs.) code.
When a record is saved, Microsoft Office Access 2007 sets the Dirty property to False. When a user makes changes to a record, the property is set to True.
The following example enables the
button when data is changed. The UndoEdits( ) subroutine is called from the AfterUpdate
event of text box controls. Clicking the enabled
button restores the original value of the control by using the OldValue
If Me. Then
Me!btnUndo.Enabled = True ' Enable button.
Me!btnUndo.Enabled = False ' Disable button.
Dim ctlC As Control
' For each control.
For Each ctlC in Me.Controls
If ctlC.ControlType = acTextBox Then
' Restore Old Value.
ctlC.Value = ctlC.OldValue