Before the user closes the form I want to prompt with a confirmation box.
I am not sure how to do this.
I have tried the code below and it prompts the user but upon clicking no it closes the form anyway:
Private Sub Form_Close()
If MsgBox("Test", vbYesNo + vbExclamation, "Confirm close") = vbYes Then
Else
Cancel = True
End If
End Sub
You can’t cancel the close event but you can cancel the unload event