I created a database with worker information. I created a login that a worker can log in to the database and go to worker details. Issue I want to do is I want only the person that log in to see his or her information and cannot look at other records. So when worker goes to the login page he or she will login in with their first name then the password is the worker ID number. After login with go to the forum worker details with the person that login in information with the correct worker ID that is the same as password. Right know I can get the worker details forum to open but cannot get it to go directly to the person name that is logging in , Here is my code. Thanks for your Help
John
Private Sub Command1_Click()
Dim User As String
Dim UserLevel As Integer
Dim TempPass As String
Dim ID As Integer
Dim workerName As String
Dim TempLoginID As String
If IsNull(Me.txtUserName) Then
MsgBox "Please enter UserName", vbInformation, "Username requeired"
Me.txtUserName.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please enter Password", vbInformation, "Password requeired"
Me.txtPassword.SetFocus
Else
If (IsNull(DLookup("LoginID", "tblworker", "LoginID = '" & Me.txtUserName.Value & "' And password = '" & Me.txtPassword.Value & "'"))) Then
MsgBox "Invalid UserName or Password!"
Else
TempLoginID = Me.txtUserName.Value
workerName = DLookup("[workername]", "tblworker", "[LoginID] = '" & Me.txtUserName.Value & "'")
UserLevel = DLookup("[UserType]", "tblworker", "[LoginID] = '" & Me.txtUserName.Value & "'")
TempPass = DLookup("[password]", "tblworker", "[LoginID] = '" & Me.txtUserName.Value & "'")
ID = DLookup("[workerid]", "tblworker", "[LoginID] = '" & Me.txtUserName.Value & "'")
DoCmd.Close
If (TempPass = "password") Then
MsgBox "Please change Password", vbInformation, "New password requeired"
DoCmd.OpenForm "frmUserinfo", , , "[workerid] = " & ID
Else
DoCmd.OpenForm "Worker Details"
End If
End If
End If
End Sub