I created a MS Access database with multiple forms. One of the form is a switchboard that leads to other forms. I wanted to make sure that the switchboard form never closes. So in the switchboard form I did:
Private Sub Form_Unload(Cancel As Integer)
Cancel = True
MsgBox "You cannot close the switchboard"
End Sub
However, I realized that when a user wants to exit the database using the close database at the top it triggers the message box above. I understand why this happens as Access probable tries to close all of the open window before closing the database.
Is there a way to change my vba to understand that the form close is coming from database close event. Or is there any better way to prevent form close?