Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whats wrong with this statement? 1

Status
Not open for further replies.

duhu

Technical User
Feb 3, 2009
5
GB
Hi guys, please help, what is wrong with this statement below which i am using on a login form?: below is part of the OnClick Event on the OK button on the login box form. The statement is supposed to check the value of the password in "tblEmployees" to see if this matches the value chosen in combo box:
--------------------------------------------------
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[strEmpName]=" & Me.cboEmployee.Value) Then

strMyEmpName = Me.cboEmployee.Value
-------------------------------------------------

I keep getting an error (as seen in attachment)

The statement used to look like the one below until i deleted the IntEmpID field from tblEmplyees. IntEmpID (numerical data) used to be the primary key but i changed it to the field "strEmpName" (Employee Username) instead (see original statement below):

----------------------------------------------------
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then

lngMyEmpID = Me.cboEmployee.Value
 
[strEmpName]='" & Me.cboEmployee.Value & "'
 
Maybe also try DLookup("[strEmpPassword]",.....

Ever notice how fast Windows runs? Me neither.
 
Why? Brackets only needed if you have reserved words or spaces in your names. Also in a few places in parameter queries.
 
My Access help file has the field name enclosed in square brackets.

Ever notice how fast Windows runs? Me neither.
 
I am not saying it is wrong, but it makes absolutely no difference and changes nothing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top