Return to Snippet

Revision: 42650
at March 8, 2011 09:35 by heislekw


Updated Code
Private Sub Form_Timer()
    ' the Timer Interval has been set at 1000, that is, once per second.
    
    Static bFlag As Boolean
    If Me.Dirty Then
        If Not bFlag Then
            Me!cmdUndo.Enabled = True
            bFlag = True
        End If
    Else
        If bFlag Then
            Me!txtFirstName.SetFocus
            Me!cmdUndo.Enabled = False
            bFlag = False
        End If
    End If
End Sub

Sub cmdUndo_Click()
    ' same action as clicking Undo from the Edit menu
    DoCmd.RunCommand acCmdUndo
End Sub

Revision: 42649
at March 8, 2011 09:30 by heislekw


Initial Code
Private Sub Form_Timer()
    ' the Timer Interval has been set at 1000, that is, once per second.
    
    Static bFlag As Boolean
    If Me.Dirty Then
        If Not bFlag Then
            Me!cmdUndo.Enabled = True
            bFlag = True
        End If
    Else
        If bFlag Then
            Me!txtFirstName.SetFocus
            Me!cmdUndo.Enabled = False
            bFlag = False
        End If
    End If
End Sub

Initial URL

                                

Initial Description
Set TimerInterval to 1000

Add a command button called cmdUndo, which will be enabled the moment the form is edited.

Initial Title
Detect if form is being edited - Option 2 (timer)

Initial Tags
form

Initial Language
Visual Basic