Interrupt formClose Event

craigachan

Registered User.
Local time
Yesterday, 21:16
Joined
Nov 9, 2007
Messages
285
How do I interupt a formclose event base on my criteria? I've tried:

Private Sub Form_Close()
If Not IsNull(Forms!NotesAnesSx!nsxDOS) And IsNull(Forms!NotesAnesSx!Start) Then
MsgBox "Please Enter Start Time"
End

End If
End Sub

But the form still closes. I want to stop the form from closing. Thanks for your help.
 
How are you closing the form? If you do it with a button then you should put your code there. I don't think you can cancel a form close event. Or you could fire the code off in the before update event which fires when the form saves the current record when it closes.
 
I have a button that can stop the form close, but I'm worried about the close (x) button on the upper right corner. My code doesn't seem to work the same way when this control is used to close the form.
 
You could remove the x button with the form properties - ?
 
If you want to cancel a form from closing, you can put code in the form's UNLOAD event and set Cancel = vbRed (just kidding about the vbRed part - although it will work because anything that doesn't return a 0 will work)

Cancel = True
 

Users who are viewing this thread

Back
Top Bottom