I have a main form with an Exit Database button that has code behind it. If someone closes the database with the X at the top of the database, the code does not get executed.
Private Sub Form_Unload(Cancel As Integer)
MsgBox "Please Close This Database By Using The" & vbCr & _
"QUIT Button Located On Main Form.", vbCritical, _
"Illegal Close"
Cancel = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Do you really want to exit " & myappname, vbYesNo + vbQuestion + vbDefaultButton2, "Confirm Exit") = vbNo Then
Cancel = vbCancel
End If
End Sub