I have a table consisting of Employee Name, Dept, Username, password.
I created a login form that will Dlookup the value of my to my EmployeeTbl.
the username is selected in combobox, then password is entered in unbound txtbox. after that, it will compare the password to my table.
The query is composed of SELECT Employeetbl.username, Employeetbl.[Employee Name], Employeetbl.Department FROM Employeetbl;
My main problem is that I cant get it work. everytime I click the logincmd button, it returns "The expression you entered as query produced this error"
my suspect is the dlookup script, which is way turning my head really bad now.
so I desperately need your knowledge to make this work.
or I wonder how DLookup really work.
Private Sub logincmd_Click()
Dim strpassword As Variant
'
'check to see if password is entered
'
If IsNull(txtpassword) = True Then
strMessage = "Please enter your password"
Style = vbCrtitical
strTitle = "No Password Entered"
MsgBox strMessage, Style, strTitle
Me.txtpassword.SetFocus
Exit Sub
End If
'
'Get the password stored in Employees Table
'
If Me.txtpassword.Value = DLookup("password", "Employeetbl", "[username]=" & Me.nameCmbo.Value) Then
username = Me.nameCmbo.Value
DoCmd.Close acForm, "LoginFrm", acSaveNo
DoCmd.OpenForm "TimeForm"
Else
strMessage = "Incorrect Password Entered"
strMessage = strMessage & vbCr & vbCr
strMessage = strMessage & "Please Enter it Again"
Style = vbCritical
strTitle = "Incorrect Password"
MsgBox strMessage, Style, strTitle
txtpassword.SetFocus
End If
End Sub