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


/ Published in: Visual Basic
Save to your folder(s)

Set TimerInterval to 1000

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


Copy this code and paste it in your HTML
  1. Private Sub Form_Timer()
  2. ' the Timer Interval has been set at 1000, that is, once per second.
  3.  
  4. Static bFlag As Boolean
  5. If Me.Dirty Then
  6. If Not bFlag Then
  7. Me!cmdUndo.Enabled = True
  8. bFlag = True
  9. End If
  10. Else
  11. If bFlag Then
  12. Me!txtFirstName.SetFocus
  13. Me!cmdUndo.Enabled = False
  14. bFlag = False
  15. End If
  16. End If
  17. End Sub
  18.  
  19. Sub cmdUndo_Click()
  20. ' same action as clicking Undo from the Edit menu
  21. DoCmd.RunCommand acCmdUndo
  22. End Sub

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.