Help With Login Screen Code! 07'

JBurlison

Registered User.
Local time
Today, 08:12
Joined
Mar 14, 2008
Messages
172
Still trying to learn VB i cant get my Login to work.:mad:

The table i have my user names and passwords stored on is called "User Name"

The user name column is "User Name" and the Password is "password"

The Login Form Name is "Login Screen" one drop down box with the user names in it named "User Names". another empty text Box Named "password"

my VB code for the login button as follows:

Code:
Private Sub Command27_Click()

    If Me.Password.Value = DLookup("[Password]", "User Name", [User Name] = Me.User_name.Value) Then

        DoCmd.Close acForm, "Login Screen", acSaveNo
        DoCmd.OpenForm "Switchboard"

    Else
      MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
            "Invalid Entry!"
        Me.Password.SetFocus
    End If

    LogonAttempts = LogonAttempts + 1
    If LogonAttempts > 3 Then
      MsgBox "You do not have permission to access this database.Please contact your database administrator."
        Application.Quit
    End If


End Sub

i know the statement is wrong, do i have to set focus's or something? Im not too Fammilar with DLookup eather i made the code soley on the help file can someone gimmie a rundown on the Dlookup Function!
Please HELP!
 
Ahhh Thanks for the DLookup info, how about the login code?

Updated the Code, nothing happens when i click the button ><. is my code still wrong?


If Me.Password.Value = DLookup("[Password]", "User Name", "[User Name] = " & User_name!User_name) Then

DoCmd.Close acForm, "Login Screen", acSaveNo
DoCmd.OpenForm "Switchboard"

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.Password.SetFocus
End If

LogonAttempts = LogonAttempts + 1
If LogonAttempts > 3 Then
MsgBox "You do not have permission to access this database.Please contact your database administrator."
Application.Quit
End If
 
Last edited:
I'm going to guess that:
Code:
If Me.Password.Value = DLookup("[Password]", "User Name", "[User Name] = " & User_name!User_name) Then
should be:
Code:
If Me.Password.Value = DLookup("[Password]", [COLOR="Red"]"[User Name]", "[User Name] = '" & Me.User_name & "'"[/COLOR]) Then
 

Users who are viewing this thread

Back
Top Bottom