Hi all,
I've realised the limitations of macros and had a quick crash course today.
I'm already stuck and was hoping to find some help here.
My form frmEditEmployee is pretty self explanatory. You can edit employee's details. Please keep in mind that when changes are made, they are saved automatically when the form is closed.
frmEditEmployee has a button cmdClose which must do the following two,
1. Undo any changes made, if any
2. Close the form
Simple enough?
Now cmdClose's purpose is to close the form WITHOUT saving any changes (if any).
I've tried using a macro, and was told that VBA is the solution to get rid of that annoying "there's nothing to undo" message when no changes are made.
Here is my code...
Now with the current code, the only way for me to close the form is to make changes first. If I don't make any changes, the form will not close.
Please help.
Thanks in advance.
I've realised the limitations of macros and had a quick crash course today.
I'm already stuck and was hoping to find some help here.
My form frmEditEmployee is pretty self explanatory. You can edit employee's details. Please keep in mind that when changes are made, they are saved automatically when the form is closed.
frmEditEmployee has a button cmdClose which must do the following two,
1. Undo any changes made, if any
2. Close the form
Simple enough?
Now cmdClose's purpose is to close the form WITHOUT saving any changes (if any).
I've tried using a macro, and was told that VBA is the solution to get rid of that annoying "there's nothing to undo" message when no changes are made.
Here is my code...
Code:
'------------------------------------------------------------
' mcrCloseFormEditEmployee <-- old deleted macro
' vbaCloseFormEditEmployee <-- new
'------------------------------------------------------------
Function vbaCloseFormEditEmployee()
On Error GoTo vbaCloseFormEditEmployee_Err
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdUndo
DoCmd.Close acForm, "frmEditEmployee"
DoCmd.SetWarnings True
vbaCloseFormEditEmployee_Exit:
Exit Function
vbaCloseFormEditEmployee_Err:
' MsgBox Error$ <-- no more error messages
Resume vbaCloseFormEditEmployee_Exit
End Function
Now with the current code, the only way for me to close the form is to make changes first. If I don't make any changes, the form will not close.
Please help.
Thanks in advance.