Password on Button

petehk

Registered User.
Local time
Today, 06:21
Joined
Oct 28, 2004
Messages
19
Any ideas on how i could password protect a button so that it does not activate unless a valid password is entered. I'm assuming i will need to add some sort of code to the OnClick event property of the button, but have no idea what the code should be. Any help gratefully accepted. :confused:
 
Not my code, Jon,Doc or ghudson ...I think

Dim strInput As String
Dim strMsg As String

Beep
strMsg = "This form is used only by the ''Special Form'' people." & vbCrLf & vbLf & "Please key the ''Special Form'' password to allow access."
strInput = InputBox(Prompt:=strMsg, title:="Special Password")
If strInput = "SpecialFormPassword" Then 'password is correct
DoCmd.OpenForm "YourSpecialFormNameHere"
DoCmd.Close acForm, Me.Name
Else 'password is incorrect
MsgBox "Incorrect Password!" & vbCrLf & vbLf & "You are not allowed access to the ''Special Form''.", vbCritical, "Invalid Password"
Exit Sub
End If
 
Works a treat. Is there any way to show the inputted password as a series of asterix rather than displaying the characters?
 
Type 'PASSWORD' in the input mask...

???
kh
 
Which input mask would that be? The code is written in VB and attached to the onclick event of a button. Thanks for the thought though.
 
My bad, didn't see you were using a inputBox. Not sure if it's possible then. You could do it with a small custom form...

kh
 
Meltdown. I thought I recognized my code. ;)

You can not format an Input Box. You will have to create a custom form to use the password input mask in a text box. I find it easier to just have a text box displayed when needed for the user to key their password and then make it not visible after they correctly enter a password. That way the password function is within the same form and only visible when needed plus you can format the text box to hide the keyed password.

UPDATE: Check this link out on how to do it with a lot of code... Disable Shift Key
 
Last edited:
Hi,
I'm trying to password protect one page in a tab control and I can't think my way out of a paper bag right now. I've looked around the forum and found some suggestions and tried to implement them. I need the password to be masked, so the input box route doesn't work. I've tried to create a global variable called "Password" (see Module1) that will be set when "txtPassword" in "frmPassword" is updated, an event which also closes the form (opened as modal). There are already problems with this so far, but I also can't figure out how to avoid the circular thing that's happening - clicking on the "secure page" triggers the process of requesting the password, which eventually triggers the process all over again once the correct password is entered. The password is "safety1st". Can anyone please help me? Thanks!!!
 

Attachments

Users who are viewing this thread

Back
Top Bottom