J
Jenna B
Hi there,
I'm working on a form that will open in Read Only mode by default.
A user can change it to Edit mode by clicking a button.
On Close, I want the user to be prompted to save their changes, but only if
it was open in Edit mode.
I've tried the following If statement (based on a post that I found with the
basic structure), but am having difficulty getting it to work. (I'm getting
Error 2501 - Not sure why.)
Thank you in advance for your help. I'm new to VBA and greatly appreciate
your guidance!
CODE:
Private Sub Form_Close()
If Forms("frmEmployees").AllowEdits Then
DoCmd.Close acForm, "frmEmployees", acSaveYes
Else
DoCmd.Close acForm, "frmEmployees", acSaveNo
End If
End Sub
I'm working on a form that will open in Read Only mode by default.
A user can change it to Edit mode by clicking a button.
On Close, I want the user to be prompted to save their changes, but only if
it was open in Edit mode.
I've tried the following If statement (based on a post that I found with the
basic structure), but am having difficulty getting it to work. (I'm getting
Error 2501 - Not sure why.)
Thank you in advance for your help. I'm new to VBA and greatly appreciate
your guidance!
CODE:
Private Sub Form_Close()
If Forms("frmEmployees").AllowEdits Then
DoCmd.Close acForm, "frmEmployees", acSaveYes
Else
DoCmd.Close acForm, "frmEmployees", acSaveNo
End If
End Sub