<the on click event doesn't want to do anything?>
What "OnClick" event?
You specified that this should happen...:
"When the user clicks the close button" ("The Close button", ...meaning *the* windows standard close button, the little "X" in the upper right side of a window)
... not...
"When the user clicks *my* close button.
So our codes are on the Close event and the Unload event receptively.
If you want the code on "Your" close button, then use code like this:
Private Sub btmClose_Click()
Dim bytAnswer As String
If Instock.Value <> 0 Then
bytAnswer = MsgBox("Exit now?", vbYesNo, "Exit?")
If bytAnswer = vbYes Then
'Do nothing
ElseIf bytAnswer = vbNo Then
Me.Instock.SetFocus
Exit Sub
End If
Else
'Do Nothing
End If
DoCmd.Close
End Sub
Remember here that you have not told us what other code (if any) is present on your close button already, so this code may need to be tweaked.
Finally, remember that when you code your own close button you have to be sure that you are covering all the contingencies for the various states that the data may be left in.
I am sure 2toria can post similar working code.
;-)
JeffCoachman