Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where to set Enabled=False for SAVE/UNDO buttons

Status
Not open for further replies.

FarmboyEsq

Programmer
Apr 2, 2007
17
US
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!
 
Private Sub cmdSaveChanges_Click()
If Me.Form.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
Screen.ActiveControl.Enabled=False
Else
MsgBox "Changes are Saved", vbOKOnly, "Save Complete"
End If
End Sub
Private Sub cmdUndoChanges_Click()
If Me.Form.Dirty Then
DoCmd.RunCommand acCmdUndo
Screen.ActiveControl.Enabled=False
Else
MsgBox "All changes have been undone", vbOKOnly, "Undo Changes Complete"
End If
End Sub


[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top