I can't tell you how to get the user name because I don't even know if you're storing it, let alone where it is. You could DLookup the name I guess. You'll notice in the revised code that I've assigned the level and temp pass to your variables first, mainly because you were looking them up twice. Look them up once, assign to variables then reference the variables as many times as necessary. I did nothing about preventing logging in if there was anyone else in already since it's not clear you wanted that, and I don't know where you're at with the exclusive option thing. Watch out for integer vs longs with user id's such as empl numbers if you ever use those. I've seen where the employee id value exceeded the capacity of the integer data type.
NOTE: I don't get what you are doing with stuff like assigning a lookup on login to a user level and then again to a usersecurity lookup. See in between the ****.
I think you'll be able to get and work with the user name using what follows as an example.
Code:
Private Sub Command1_Click()
Dim UserLevel As String
Dim TempPass As String
Dim ID As Integer
'get user id and password
If IsNull(Me.txtLoginID) Then
MsgBox "Please enter LoginID", vbInformation, "LoginID Required"
Me.txtLoginID.SetFocus
Exit Sub
End If
If IsNull(Me.txtpassword) Then
MsgBox "Please enter Password", vbInformation, "Password Required"
Me.txtpassword.SetFocus
Exit Sub
End If
'validate id and password
UserLevel = DLookup("[Userlogin]", "tblUser", "[Userlogin] =" & Me.txtLoginID)
TempPass = (DLookup("[Password]", "tblUser","[Password] = '" & Me.txtpassword & "'")
If IsNull(UserLevel) OR IsNull(TempPass) Then
MsgBox "Incorrect LoginID or password"
Exit Sub
End If
'****Process the job
UserLevel = DLookup("UserSecurity", "tblUser", "Userlogin ='" & Me.txtLoginID.Value & "'")
TempPass = DLookup("password", "tblUser", "Userlogin ='" & Me.txtLoginID.Value & "'")
ID = DLookup("UserID", "tblUser", "Userlogin ='" & Me.txtLoginID.Value & "'")
DoCmd.Close
'****
If UserLevel = "user" Then
DoCmd.OpenForm "frmRunReport"
Else
DoCmd.OpenForm "MainForm"
End If
End Sub