On close command I have code which ask me if I want to save changes before closing (yes, no, cancel).
If I say yes then in before update there is a code which checks if all required fields are filled.
In case they aren't it notify me but still form is close. How to stop closing in that case?
Code:
Private Sub Close_Click()
bSaving = True
If Me.Dirty Then
answer = MsgBox("Do you want to save changes before closing?", vbYesNoCancel + vbQuestion, "Confirm Save")
If answer = vbNo Then
Me.Undo
DoCmd.Close acForm, Me.Name
ElseIf answer = vbYes Then
On Error Resume Next
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name
End If
Else
DoCmd.Close acForm, Me.Name
End If
bSaving = False
End Sub
If I say yes then in before update there is a code which checks if all required fields are filled.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer) If IsNull(Me![cbo_AssignedFrom]) Then MsgBox "You must enter who is Assign from before this Record can be saved" Cancel = True: Me![cbo_AssignedFrom].SetFocus
Comment