I created a form to have users log in. I was able to get everything to work except 1 thing.
When a new user is created they are assigned a password of Password. If they use that password it brings them to a form to change the password and this all works.
The problem I have is this, When they change the password, both the new password AND the temporary password will let them in and I cannot figure out why it does this.
Code:
Dim Userlevel As IntegerDim TempPass As String
Dim ID As Integer
Dim UserVarTemp As String
'TempPass is for Temporaty Password given to the new user
Me.PassTB = DLookup("Password", "Users_TBL", "Username='" & Me.Username.Value & "'")
If IsNull(Me.Username) Then
MsgBox "Please Enter a Valid Username!", vbInformation, "Username REQUIRED!"
Me.Username.SetFocus
ElseIf IsNull(Me.Password) Then
MsgBox "Please Enter a Valid Password!", vbInformation, "Password REQUIRED!"
Me.Password.SetFocus
Else
If (IsNull(DLookup("Username", "Users_TBL", "Username='" & Me.Username.Value & "'"))) Or _
IsNull(DLookup("Password", "Users_TBL", "Password='" & Me.Password.Value & "'")) Then
MsgBox "Username or Password is Incorrect!", vbCritical, "Login Denied!"
Me.Username = ""
Me.Password = ""
Me.Username.SetFocus
ElseIf StrComp(Me.PassTB, Me.Password, vbBinaryCompare) <> 0 Then
MsgBox "Password is Incorrect!", vbInformation, "Authentication Error!"
Else
Userlevel = DLookup("[SecurityLevel]", "Users_TBL", "Username='" & Me.Username.Value & "'")
TempPass = DLookup("[Password]", "Users_TBL", "Username='" & Me.Username.Value & "'")
ID = DLookup("UserID", "Users_TBL", "Username='" & Me.Username.Value & "'")
UserVarTemp = Me.Username
If (TempPass = "Password") Then
DoCmd.OpenForm "ChangePassword_FRM", , , "[userid]=" & ID
Else
If Userlevel < 15 Then
DoCmd.OpenForm "HFCAMainmenu_FRM"
Forms![HFCAMainMenu_FRM]!CurrentUserTB = UserVarTemp
Else
MsgBox "You do not have Access to this area! Please contact the Systems Administrator for assistance.", vbInformation, "Not Authorized"
End If
End If
End If
End If
End Sub
Any assistance would be appreciated