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

Windows User Name and Access

Status
Not open for further replies.

MrMajik

IS-IT--Management
Apr 2, 2002
267
I would like to add a feature that would make the main form of my Access program aware of who the person is that opened the database.

Can Access be aware of the user ID (or login name) that a person used when they logged into the workstation or network domain?


Thank you,

MrMajik

There are 10 types of people in the world:
Those that understand binary and those that don't.
 
MrMajik,
Did you try [tt]Environ("USERNAME")[/tt] (or [tt]Environ$("USERNAME")[/tt])? This will return the Windows Log On Id in Windows NT 4.0 or newer.

If you use ActiveDirectory for authentication you can even go a step further:
Code:
Public Function ADsFullName() As String
[green]'This function requires a reference to Active DS Type Library (activeds.tlb)
'Will work in any office application that will allow you to write and run a macro[/green]
Dim objIADsUser As ActiveDs.IADsUser
Dim strUserID As String, strComputerName As String
strComputerName = Environ$("COMPUTERNAME")
strUserID = Environ$("USERNAME")
Set objIADsUser = GetObject("WinNT://" & _
  strComputerName & "/" & strUserID & ",user")
ADsFullName = objIADsUser.FullName
Set objIADsUser = Nothing
End Function

Hope this helps,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top