Password on Command button

  • Thread starter Thread starter Sarah M
  • Start date Start date
S

Sarah M

Is there a way to put a password on a commnad button? I would like it so
that If a user clicked on it they whould be prompted for a password in order
to continue.

Thanks for any help.
 
Sarah M said:
Is there a way to put a password on a commnad button? I would like it so
that If a user clicked on it they whould be prompted for a password in order
to continue.

A very basic way...

If InputBox("Enter Password") = "YourPassword" Then...
 
heres the code to put it on any object, a picture,
button...
On the On DBL Click...expression...code...
type: Docmd.Openform"password"
then make up a form called: password.
have a enter button, cancel button, and a unbound text box
with a password imput mask (so no one can see your
password) This is the only way to use a input mask...the
input box cmd wont let you.

on the form design click on the enter button....On click
event....code. enter this into the visual basic editor.

Private Sub Enter_Click()
Dim stlinkcriteria As String
Dim stDocName As String
On Error GoTo errorhandler
If Password = "the passowrd your using" Then
DoCmd.Close acForm, "Password", acSaveNo

stDocName = "Form that will open after password"
DoCmd.OpenForm stDocName, , , stlinkcriteria
Else
' the entered password was incorrect
MsgBox "Sorry, the password you have " & "entered is
incorrect." & vbNewLine & " Please contact Admin for
assistance.", vbExclamation, "Access is Denied"
End If

'open the protected form
'then close this form
Exit Sub
errorhandler:
MsgBox Err.Description, vbCritical, "Error #" & Err.Number

End Sub

I hope this helps

Timothy
 
Back
Top