1) Declare a variable at the top of the form module:
Private CanClose As Boolean
2) Create an On Unload event procedure for the form:
Private Sub Form_Unload(Cancel As Integer)
Cancel = Not CanClose
End Sub
3) Make the code for the command button look like this:
Private Sub cmdClose_Click()
CanClose = True
DoCmd.Close acForm, Me.Name
End Sub
Regards, Hans Vogelaar (http://www.eileenslounge.com)