I have designed a form in which when the user clicks the "Close" button in the top right hand corner, a msgbox will popped up. If user clicks "Cancel" in the msgbox, the form will NOT be closed.
As shown below, I have tried: Me.Undo
However, it doesn't work.
Private Sub Form_Close()
On Error GoTo Err_form_close
Dim response
response = MsgBox("Do you want to close the form without saving current records?", vbOKCancel, "Notics"
If response = vbOK Then
...
ElseIf response = vbCancel Then
Me.Undo <-- WRONG
End If
End Sub
Can anyone tell me how can I return to the form instead of closing it, if the user clicks "Cancel" in the msgbox?
As shown below, I have tried: Me.Undo
However, it doesn't work.
Private Sub Form_Close()
On Error GoTo Err_form_close
Dim response
response = MsgBox("Do you want to close the form without saving current records?", vbOKCancel, "Notics"
If response = vbOK Then
...
ElseIf response = vbCancel Then
Me.Undo <-- WRONG
End If
End Sub
Can anyone tell me how can I return to the form instead of closing it, if the user clicks "Cancel" in the msgbox?