In a form I want a dlookup to return the text value in UserAccess field in my table tblEmployees where the value in the table field strEmpName matches the value entered in text box txtUsername on the same form.
I've entered the below dlookup in the form textbox but it keeps returning a Name? error.
Also, Access keeps adding the square brackets around Me.txtUsername.
Can anyone please shed any light on why I'm getting the error and why Access is placing the brackets around the control name?
I've entered the below dlookup in the form textbox but it keeps returning a Name? error.
Also, Access keeps adding the square brackets around Me.txtUsername.
Code:
=DLookUp("UserAccess","tblEmployees","strEmpName = '" & Me.txtUsername & "'")
Code:
=DLookUp("UserAccess","tblEmployees","strEmpName = '" & [Me].[txtUsername] & "'")
Can anyone please shed any light on why I'm getting the error and why Access is placing the brackets around the control name?