Hi
Where am I wrong, When the user clsoe the form, I want to make sure that the Comment field is not empty. If its empty, then force them to enter and shouldnot close the form. else if its entered, then close the form. Why is DoCmd.CancelEvent not working?
Private Sub Form_Close()
Text1.SetFocus
If (Text1.Text = "") Then
MsgBox ("Your comment field cannot be empty, Please enter before close.")
DoCmd.CancelEvent
Exit Sub
Else
MsgBox ("You are ready to close")
End If
End Sub
Thanks.
Where am I wrong, When the user clsoe the form, I want to make sure that the Comment field is not empty. If its empty, then force them to enter and shouldnot close the form. else if its entered, then close the form. Why is DoCmd.CancelEvent not working?
Private Sub Form_Close()
Text1.SetFocus
If (Text1.Text = "") Then
MsgBox ("Your comment field cannot be empty, Please enter before close.")
DoCmd.CancelEvent
Exit Sub
Else
MsgBox ("You are ready to close")
End If
End Sub
Thanks.