Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Applies to

Form Object

Report Object

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.Dirty

expression Required. An expression that returns one of the objects in the Applies To list.

Remarks

The Dirty property uses the following settings.

Setting

Visual Basic

Description

True

True

The current record has been changed.

False

False

The current record has not been changed.

This property is available in Form view and Datasheet view.

This property set or read using a macro or Visual Basic for Applications (VBA) 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.

Example

The following example enables the btnUndo button when data is changed. The UndoEdits( ) subroutine is called from the AfterUpdate event of text box controls. Clicking the enabled btnUndo button restores the original value of the control by using the OldValue property.

Sub UndoEdits()
If Me.Dirty Then
Me!btnUndo.Enabled = True ' Enable button.
Else
Me!btnUndo.Enabled = False ' Disable button.
End If
End Sub
Sub btnUndo_Click()
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
End If
Next ctlC
End Sub

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×