DLookup problem in Access 2007

LB79

Registered User.
Local time
Today, 20:43
Joined
Oct 26, 2007
Messages
505
Hello,

I'm having a problem with DLookup (I think that’s what I need to be using).
In capturing the users windows name in a separate function and storing it as ‘User’.
I want then to match the ‘User’ name against a table to return the full name of the person.
When I use the below I get Runtime 2471 the expression you entered as a query parameter produced this error: ‘MyWindowsUserName’.

NB MyWindowsUserName has replace my actual windows user name.

Thanks for any advice.

Code:
[SIZE=3][COLOR=#000080][FONT=Arial]Private Sub Command0_Click()[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Call User [/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Dim MyID As String[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]MyID = DLookup("Name", "tbl_User", "[UserID] =" & User())[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Me.Text1 = MyID[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]End Sub[/FONT][/COLOR][/SIZE]



In table ‘tbl_User’, ‘UserID’ is the windows name, ‘Name’ is the full name of the person.

PS – This is in Access 2007.

Thanks
 
DLookup("Name", "tbl_User", "[UserID] =" & User())

Change to

DLookup("Name", "tbl_User", "[UserID] ='" & User() & "'")


Thas is if User() is a string value, and UserID is a string as well.
 
Instead of managing a table of user names just to retrieve their full name why not get their full name from their network ID?
Check this thread out... get real user name
 

Users who are viewing this thread

Back
Top Bottom