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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"=DLookUp("[Name]",tblusers","CurrentUser() = [UserID]&

Status
Not open for further replies.

gyli84

MIS
Aug 6, 2001
67
GB
I have secured my database with Access User Level Security and workgroups and now users are required to log on to access it. I have a table called "tblUsers" which contains "UserID" and "Name" amongst other fields. The people who log into the database use the same User IDs as corresponds to their record in "tblUsers". What I would like to do is place a text box on a form which will display the Name (not the user ID of the person who has logged in). I can easily get the textbox to show the Current user using "=[currentuser]" as the control source but this is not what I want. I have tried:

"=DLookUp("[Name]",tblusers","CurrentUser() = [UserID]")" but the control source returns #Name?
 
I have also tried creating a query which has UserID and Name and the criteria of the UserID is [Forms]![frmManagerMenu]![Currentuser] where currentuser is a textbox on the form (=[currentuser]

What else can I do or what is going wrong!? Help!!

Thanks
 
You need to know the UserId in order to get the information from the table tblUsers.

Your DlookUp call should look like this:

Dlookup("[Name]","tblUsers","UserId = '" & ??? & "'")

The ??? should be a variable or reference to a text box that contains the login UserId. You should be able to set this in the Open event of the form.
 
I have the textbox "LoginID" with the control source =[currentuser] on the same form (frmManagerMenu) as the textbox in which I want to use Dlookup to display the currentuser's name. How should I enter the reference to the "LoginID" textbox where you have put ??? I have tried:

LoginID
[LoginID]
[Forms]![frmManagerMenu]![LoginID]

all to no avail. it still returns #Name?
 
Double check your table name and column names.
Usually #Name means it can not find the table or column.
 
I have tried"

"=DLookUp("[Name]","Staff","CurrentUser() = [User ID]")"

I clearly have a table named "Staff" with the field [Name] and another called [User ID] yet this expression in the control source of a text box still returns #Name?
 
OK, solved the problem, thanks for the help everyone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top