I have added the VBA code below to my form which is Named Main. I place code in the Close event. It works like a charm when I enter the password (Access123). However when I enter a different word it gives me my message box that states “You're not authorized” like it should but then when I hit OK on message box I get Microsoft Visual Basic Runtime Error ‘2501’: the close action was cancelled when I hit End it closes form anyhow and when I hit Debug it shows code with password. Any Clues??? I am using Office Access 365 I would love it if the code would revert back and ask for code to be reentered until the actual code is entered which than would allow form to be closed. Once again thanks everyone on this forum for all the help and support I have learned so much from everyone.
Dim PassWord As String
PassWord = InputBox("Enter Password")
If PassWord = "Access123" Then
' Open Form
MsgBox ("You're not authorized")
DoCmd.Close acForm, Me.Name