Password protection

brucewalker

Registered User.
Local time
Today, 18:38
Joined
Jul 19, 2012
Messages
14
I am looking for code I can use to prompt for a password when opening a form with a command button. I want to restrict who can open this form and I can t seem to find antythig that works..:banghead:

thanks.
 
Relate to the password, do you want to build a fix password or dynamic password for each user?

I prefer dynamic one. For this, pls make user table where you can keep the dynamic password for each user. If you like you can also make another table for group level security (eg. administrator, reader, editor, etc.).

Then prepare login form consist of 2 textboxes, for username and password.

You can try using this code for Command Button in your Login Form :
Code:
If IsNull(cboUserName)=True Then
    MsgBox "Username is a must"
Elseif IsNull(txtPassword)=True Then
    MsgBox "Password is a must"
Else
    If Me.txtPassword=DLookup("Password", "tblUsers", "[UserName]= '" & Me.cboUserName & "'") Then
        DoCmd.Close acForm, "frmLogin", acSaveNo
        DoCmd.OpenForm "frmMenu"
    Else
        MsgBox "Invalid Password. Please try again.", vbOKOnly, "Invalid Password"
        txtPassword.SetFocus
    End If
End If

Hoping this helps. :)
 

Users who are viewing this thread

Back
Top Bottom