Ok I've made this work before but can't get it to do it this time. When the user hits X on the form the user is aske if he/she wants to save changes yes and no work fine but the form still unloads if you hit cancel...

code:

Private Sub Form_Unload(Cancel As Integer)
If NoteDirty Then
Dim z
z = MsgBox("Would you like to save changes?", vbYesNoCancel, "Save changes?")
If z = 6 Then
mnuFileSave_Click
ElseIf z = 2 Then
Exit Sub
Else
'oh well
End If
End If
End Sub

Its a replacement for notepad since mine is screwed for some reason....

Thankz