Create a password for a button

Beat

Registered User.
Local time
Today, 14:03
Joined
Nov 28, 2012
Messages
14
Hello,

I have a switchboard and on that switchboard I have some buttons. Now I would like to set a password for some of those buttons. For example:

I have two buttons, one that shows all staffmembers and the info, and one button to put in a new staffmember in the database. I would like to create a password for that last button so only I can put in a staffmember into the database.

Is this possible and where can I find more information about this?

Thanks in advance.
 
So what you need is on the click of the button call a Password Input Box, and obtain a password, if the password matches then grant the privilege to add data to the table..
 
I assume you have fields for UserName and Password. If that is the case, create a Password Button and on the events code insert the code attached replacing Username, Password, and Form with your dbases' names.

Private Sub PasswordButton_Click()
Me!UserName.SetFocus


zUserName = Me!UserName
zPassWord = Me!PassWord

'MsgBox "UserName = " & zUserName & vbCr & "PassWord = " & zPassWord

If zUserName = "[UserName]" Then
If zPassWord = "[Password]" Then
'MsgBox "[good place for a message]"
DoCmd.Close

DoCmd.OpenForm "[form_you_want-to_use]", acNormal
'Exit Do
Else
MsgBox "Invalid PassWord" & vbCr & vbCr & "Re-Enter PassWord and...try again"
End If
Else
MsgBox "Invalid UserName = " & zUserName & vbCr & vbCr & "Enter correct UserName" & vbCr & " ...try again"
End If


End Sub



Have fun!!:)
 
Yes, that's exactly what I mean.
 
How do I Get the code behind the button, do I put that in a query and link that query to the button?
 
Beat, are you trying the sample my version of authenticating user?? Which I have in Code repository section?? If so, try opening the VBA editor by pressing ALT+F11 you can see the code..
 
I will take a look at it, thanks! If I can't figure it out I will come back on it.
 
I assume you have fields for UserName and Password. If that is the case, create a Password Button and on the events code insert the code attached replacing Username, Password, and Form with your dbases' names.

Private Sub PasswordButton_Click()
Me!UserName.SetFocus


zUserName = Me!UserName
zPassWord = Me!PassWord

'MsgBox "UserName = " & zUserName & vbCr & "PassWord = " & zPassWord

If zUserName = "[UserName]" Then
If zPassWord = "[Password]" Then
'MsgBox "[good place for a message]"
DoCmd.Close

DoCmd.OpenForm "[form_you_want-to_use]", acNormal
'Exit Do
Else
MsgBox "Invalid PassWord" & vbCr & vbCr & "Re-Enter PassWord and...try again"
End If
Else
MsgBox "Invalid UserName = " & zUserName & vbCr & vbCr & "Enter correct UserName" & vbCr & " ...try again"
End If


End Sub



Have fun!!:)

Could you tell me what you mean with field for Username and Password? Do I have to make a special table for that?
 
Yes Username and Password belongs to the table.. Did you see the code behind the sample I uploaded?
 
Yes I have seen the code. A other question just pops in mind.
If I make a form with the password in it, other people could just open that form and look for the password.

How can I solve this? Do I have to make a password so nobody can open that form or is it possible that nobody can see the forms/queries etc on the left.
 
Just your basic text boxes for the user to enter a UserName and Password and a button to execute the event.
 

Users who are viewing this thread

Back
Top Bottom