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

Get User Name

Status
Not open for further replies.

priac

Technical User
Feb 8, 2002
47
US
I will by saying I am not a programmer. Back in 2003 Chrissiel sent me this code to get the name of person logging into the database. After all these years, we converted to 64 bit version and this code doesn't work. Can anyone correct the code for me???
Aubrey Price
Chief Pilot
Airborne Imaging


chrissie1 (Programmer)
19 Jan 03 09:27
create a module mile you create a table in the database window

copy this piece of code in the module and save it and close it

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If ( lngX > 0 ) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function


now in the defaultvalue you put this fsousername() this will give you the username you use to login to the network (domain)

"What a wonderfull world" - Louis armstrong
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top