On a form I have a command button. I want to create a msgbox that lets the
user enter a password to go to the next form or just quit if not correct 3
times password "Supervisor" Thanks for all the help
Msgbox "What is the Password"
If password = "Supervisor" then
form.nextone
else
cmd.exit
endif
You can't use a MsgBox, but you can use a form.
Create a new form.
Add an unbound control named "txtPassword"
Set it's Input Mask property to "Password"
Name this new form "frmPassword"
Add a command button to this form.
Code this command button click event:
Static Counter As Integer
If txtPassword = "supervisor" Then
Me.Visible = False
Else
If Counter < 2 Then
MsgBox ("The password you entered is invalid. Please try
again.")
Counter = Counter + 1
Else
DoCmd.Quit ' exit the database
End If
End If
========
Code the command button on your current existing form:
DoCmd.OpenForm "frmPassword", , , , , acDialog
If Not CurrentProject.AllForms("frmPassword").IsLoaded Then
Exit Sub
End If
DoCmd.OpenForm "TheNextForm"
DoCmd.Close acForm "frmPassword"
==============
It would be wise to hide the frmPassword from your users by
right-clicking on the form (on the main database folder) and choosing
Properties. Place a check in the Hidden Attributes box.
You would then show the form again, if needed, by clicking
Tools + Options + View + Show Hidden Objects