Article ID: 123595
Article Last Modified on 1/19/2007
Name: txtEditModeChange
ControlSource: =[Form].[Dirty] & CheckUndo([Form])
Visible: No
Sub Form_AfterUpdate ()
' Because the record is being saved, which changes the edit mode, the
' bookmark should be reset so that it will appear to the CheckUndo()
' function that the user moved to another record.
PrevBookmark = Null
End Sub
Option Explicit
Dim PrevBookmark
Function CheckUndo (F As Form) As Variant
Dim CurrBookmark
' Is the record clean (not dirty)?
If Not F.Dirty Then
' If so, get the current bookmark.
On Error Resume Next
CurrBookmark = F.bookmark
' If an error occurred, this is the new record.
If Err Then CurrBookmark = "NewRecord"
' Determine if the edit change occurred on the same record (the
' record was undone, as opposed to moving to another record).
If StrComp(CurrBookmark, PrevBookMark, 0) = 0 Then
' The record was undone.
AfterUndo
Else
' The record was not undone (moved to another
' record). Record the bookmark of the current
' record for the next iteration.
PrevBookmark = CurrBookmark
End If
End If
End Function
Sub AfterUndo ()
' Add the code you want to run when the record is undone here.
End Sub
Sub AfterUndo ()
MsgBox "Record Changes Undone"
End Sub
122294 ACC: How to Automatically Detect If a Form Is Being Edited
Additional query words: onundo
Keywords: kbhowto kbprogramming kbusage KB123595