FarmboyEsq
Programmer
Hello -- 1st time poster and MS Access 2003 novice here!
I've adapted a bit of VBA code that gives me nice Save and Undo buttons. These buttons are correctly enabled/disabled as follows:
Private Sub Form_Current()
Me!cmdUndoChanges.Enabled = False
Me!cmdSaveChanges.Enabled = False
End Sub
Private Sub Form_Dirty(Cancel As Integer)
Me!cmdUndoChanges.Enabled = True
Me!cmdSaveChanges.Enabled = True
End Sub
And, when clicked the code behind them works well. However, once clicked, they don't return to Enabled=False. They stay enabled. I am unable to set them to False in the click event. Other events I've tried have not worked either. Here's what I ended up coding in the Save & Undo Click events (to allow them to (wrongly) click save or undo twice):
Private Sub cmdSaveChanges_Click()
If Me.Form.Dirty Then
DoCmd.RunCommand acCmdSave
Else
MsgBox "Changes are Saved", vbOKOnly, "Save Complete"
End If
End Sub
Private Sub cmdUndoChanges_Click()
If Me.Form.Dirty Then
DoCmd.RunCommand acCmdUndo
Else
MsgBox "All changes have been undone", vbOKOnly, "Undo Changes Complete"
End If
End Sub
Any thoughts would be appreciated.
Thank you!
I've adapted a bit of VBA code that gives me nice Save and Undo buttons. These buttons are correctly enabled/disabled as follows:
Private Sub Form_Current()
Me!cmdUndoChanges.Enabled = False
Me!cmdSaveChanges.Enabled = False
End Sub
Private Sub Form_Dirty(Cancel As Integer)
Me!cmdUndoChanges.Enabled = True
Me!cmdSaveChanges.Enabled = True
End Sub
And, when clicked the code behind them works well. However, once clicked, they don't return to Enabled=False. They stay enabled. I am unable to set them to False in the click event. Other events I've tried have not worked either. Here's what I ended up coding in the Save & Undo Click events (to allow them to (wrongly) click save or undo twice):
Private Sub cmdSaveChanges_Click()
If Me.Form.Dirty Then
DoCmd.RunCommand acCmdSave
Else
MsgBox "Changes are Saved", vbOKOnly, "Save Complete"
End If
End Sub
Private Sub cmdUndoChanges_Click()
If Me.Form.Dirty Then
DoCmd.RunCommand acCmdUndo
Else
MsgBox "All changes have been undone", vbOKOnly, "Undo Changes Complete"
End If
End Sub
Any thoughts would be appreciated.
Thank you!