Good day
I created a database in Access 2010 and now after opening it in Office 365 i found some of the functions previously done not working properly. I would be happy if I can get some help on one of the issues in my database now; I would like to display the current user of the database based on the person's User Login and not the Environ (computer's name). The fields in my table are User Name, User Login, Password, User Security. Below is the code i currently have and worked in the previous version of access.
Code:
Private Sub Command1_Click()
Dim TempPass As String
Dim ID As Integer
Dim UserName As String
Dim AccessLevel As Integer
If IsNull(Me.TxtLoginID) Then
MsgBox "Please enter LoginID", vbInformation, "LoginID Required"
Me.TxtLoginID.SetFocus
ElseIf IsNull(Me.TxtPassword) Then
MsgBox "Please enter Password", vbInformation, "Password Required"
Me.TxtPassword.SetFocus
Else
'process the job
If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin ='" & Me.TxtLoginID.Value & "' And password = '" & Me.TxtPassword.Value & "'"))) Then
MsgBox "Incorrect LoginID or Password"
Else
TempPass = DLookup("password", "tblUser", "UserLogin = '" & Me.TxtLoginID.Value & "'")
UserName = DLookup("[UserName]", "tblUser", "[UserLogin] = '" & Me.TxtLoginID.Value & "'")
ID = DLookup("UserID", "tblUser", "UserLogin = '" & Me.TxtLoginID.Value & "'")
AccessLevel = DLookup("UserSecurity", "tblUser", "UserLogin = '" & Me.TxtLoginID.Value & "'")
DoCmd.Close
If (TempPass = "password") Then
MsgBox "Please Change Password", vbInformation, "New Password Required"
DoCmd.OpenForm "tblUser", , , "[UserID] =" & ID
Else
DoCmd.OpenForm "MAIN SCREEN"
Forms![MAIN SCREEN]![TxtUser] = UserName
Forms![MAIN SCREEN]![txtsecurity] = AccessLevel
Call Security(AccessLevel)
End If
End If
End If
End Sub
.
All of this work if i use the CurrentUser = Environ ("UserName") but i dont want to use the environ name i want the name of the person based on their Username and Password which come from the user table in my database. Thanks for any help.