Keep form from closing

G

Guest

I searched the forum and found a code to keep users from closing a form if
they had not filled in a required field. My problem is, the form closes
anyway instead of staying open so they can fill in the field.

Here's the code....what am I doing wrong?

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me!subfrmUpdateQ!cbxReason) Then
Cancel = True ' cancel update
MsgBox "You must select a Reason/Note.", _
vbOKCancel, "Required Field"
Me!subfrmUpdateQ!cbxReason.SetFocus
End If

End Sub
 
D

Douglas J. Steele

BeforeUpdate isn't the correct event. Try the form's Unload event instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top