Getting NT User Login Names from Access 2000 or 2003
- From: "Michael Miller" <MichaelMiller@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 22 Jun 2005 12:35:07 -0700
I have a function called fOSUserName, that I found, to get the login name of
the person, when they open my main form.
code:
Private Declare Function apiGetUserName Lib "C:\WINNT\system32\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
Dim lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen - 1)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen)
Else
fOSUserName = vbNullString
End If
End Function
Problem is that it's returning mmiller followed by a bunch of square boxes.
The Left$ (in the code) and a try of Trim and a LTrim(RTrim()) is not fixing
it. When I try to assign it to a field in a log table, it always says that
my data is too big for the field.
When I assign it to a label, it shows up fine, as the boxes are not visible.
Any ideas? Thanks.
--
MichaelM
.
- Follow-Ups:
- Re: Getting NT User Login Names from Access 2000 or 2003
- From: John Griffiths
- Re: Getting NT User Login Names from Access 2000 or 2003
- From: Jeff Conrad
- Re: Getting NT User Login Names from Access 2000 or 2003
- Prev by Date: Eof
- Next by Date: File Sharing Lock Count Exceeded
- Previous by thread: Eof
- Next by thread: Re: Getting NT User Login Names from Access 2000 or 2003
- Index(es):
Relevant Pages
|
Loading