T
Tara
I have a form that uses some code when it's about to be closed that confirms
the user either A - wants to close the form without saving data changes or B
- wants to cancel the Close operation and save the data first. It works fine
except that it also appears even if the form has no data or no data has been
edited. I would like to code it so that if the user made no changes or the
record is empty, the MsgBox doesn't appear. For instance, if the user opened
the form by mistake and simply wants to close out before any data has even
been entered. Here's the code currently:
Private Sub cmdAddFam_Click()
On Error GoTo Err_cmdAddFam_Click
Select Case MsgBox("WARNING! You are about to close the form without
saving the data. " & _
"Are you sure you want to continue?", vbOKCancel)
Case vbOK
Me.Undo
DoCmd.Close acForm, "FrmAddClient", acSaveNo
Case vbCancel
Exit Sub
End Select
Exit_cmdAddFam_Click:
Exit Sub
Err_cmdAddFam_Click:
MsgBox Err.Description
Resume Exit_cmdAddFam_Click
End Sub
Thanks!
the user either A - wants to close the form without saving data changes or B
- wants to cancel the Close operation and save the data first. It works fine
except that it also appears even if the form has no data or no data has been
edited. I would like to code it so that if the user made no changes or the
record is empty, the MsgBox doesn't appear. For instance, if the user opened
the form by mistake and simply wants to close out before any data has even
been entered. Here's the code currently:
Private Sub cmdAddFam_Click()
On Error GoTo Err_cmdAddFam_Click
Select Case MsgBox("WARNING! You are about to close the form without
saving the data. " & _
"Are you sure you want to continue?", vbOKCancel)
Case vbOK
Me.Undo
DoCmd.Close acForm, "FrmAddClient", acSaveNo
Case vbCancel
Exit Sub
End Select
Exit_cmdAddFam_Click:
Exit Sub
Err_cmdAddFam_Click:
MsgBox Err.Description
Resume Exit_cmdAddFam_Click
End Sub
Thanks!