login form issue

joesstlouis

Registered User.
Local time
Today, 16:18
Joined
Feb 20, 2006
Messages
10
Currently I have a simple login for with a username textbox password textbox and a command button... I found a script on this site which uses a combo box for the username but I want the database slightly more secure than leaving the username there all the time. How can I get the username box to "authenticate" itself with the tblLogin I have setup with usernames and passwords in it... here's the code:

If IsNull(Me.txtUsername) Or Me.txtUsername = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.txtUsername.SetFocus
Exit Sub
End If

'Check to see if data is entered into the password box

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If

'Check value of password in tblLogin to see if this
'matches value chosen in combo box

If Me.txtPassword.Value = DLookup("Password", "tblLogin", "[UserID]=" & Me.txtUsername.Value) Then


'Close logon form and open splash screen

DoCmd.Close acForm, "frmLogin", acSaveNo
DoCmd.OpenForm "frmMainMenu"

ElseIf Me.txtLogonAttempts > 2 Then
MsgBox "You do not have access to this database. Please contact admin.", vbCritical, "Restricted Access!"
Application.Quit

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
Me.txtLogonAttempts = Me.txtLogonAttempts + 1

End If
 

Users who are viewing this thread

Back
Top Bottom