Msgbox question

B

bladelock

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
 
K

Klatuu

You can't do that with a message box. You could use an Input box, but there
is not input mask for an Input box, so the password would be visible when
entered. I suggest a small popup modal form.
 
F

fredg

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
 
T

The Provider

This will do what you ask for. Set this in code in the "OnLoad" for the form
you intend the password to open ("Your Form").

Dim Password, Loggin
Password = "Surströmming"
Loggin = InputBox("Enter password")
If Loggin <> Password Then
MsgBox "Sorry wrong password!!"
DoCmd.Close
Else
DoCmd.OpenForm "Your Form"
End
End If
 
Top