Passwording a Button :)

Rhids

New member
Local time
Today, 13:45
Joined
Jul 21, 2004
Messages
8
Bearing in mind I probably shouldn't be playing with code in general if I have to ask this ^_^ But can anyone tell me how to add this code to a bottons "On Click" event ?

The code is stored as a module and I cannot see an option to add a module to do this :/ The codes from this Forum and written by Hayley and looks ideal for the job I want it for :)

Code:
Private Sub CmdOpenResFrm_Click()

Dim strPasswd

strPasswd = InputBox("Enter Password", "Restricted Form")

If strPasswd = "blueoxford" Then

DoCmd.OpenForm "FrmName", acNormal

Else

MsgBox "Password Incorrect"

Exit Sub

End If

End Sub

Anyother suggestions on how to do this another way would be great also :)
Many Thanks
 
Code:
Private Sub CmdOpenResFrm_Click()

    Const strPasswd = "blueoxford"

    If InputBox("Enter Password", "Restricted Form") = strPasswd Then
        DoCmd.OpenForm "FrmName", acNormal
    Else
        MsgBox "Password Incorrect", vbExclamation
        Exit Sub
    End If
End Sub

Copy the bits between Private Sub cmdOpenResFrm() and End Sub.

On your command button, select it's Click event and select Code Builder.

Paste the copied section here.
 
Perfect :)

Thanks alot
 
Hi Mile,

I'd just like to say a big thank you for your password button (on-click) code.
I have manage to incorporate it into my own database which is still currently under construction.

Can I ask, I noticed that when typing in the password, anyone else watching the screen at that time could possibly see the protected password. Is there any way that as the user is typing in the password, the dialog box types **** as opposed to characters - (which in turn, will prevent any other users looking at the screen from seeing password text)?

Any help would be greatly appreciated.

Also, I hope Glasgow becomes warmer over the weekend, as I am OFF until Monday!!!!!
 
Last edited:
You can not format an inputbox. You need to either create a new form to use just for validating passwords or create a text box on the form to appear when needed for the password function. You can format the textbox with an inputmask to hide the keyed entry into the textbox.
 
thanx Ghudson,

It's ok m8, I am not going to goto that bother. I will just tell them thatthey need to ensure nobody's watching over the sys whilst accessing sensitive data.

kind regards m8
 
charlesandrews said:
Can I ask, I noticed that when typing in the password, anyone else watching the screen at that time could possibly see the protected password. Is there any way that as the user is typing in the password, the dialog box types **** as opposed to characters - (which in turn, will prevent any other users looking at the screen from seeing password text)?

AS ghudson says, a quick form with a textbox and a command button should suffice.

Code:
If Me.txtPassword = strPasword Then
    MsgBox "Correct!"
Else
    MsgBox "Wrong!"
End If


Also, I hope Glasgow becomes warmer over the weekend, as I am OFF until Monday!!!!!

Typically, that's what weekends are for. After last night's rain, I'm hoping for some more.
 

Users who are viewing this thread

Back
Top Bottom