Re: login id



I found this code (Dev's?) for a module in an earlier post sometime in
the last month...

It works like a charm. It writes the Windows Login ID nicely.

The way I am using it is to call the code from a form where the user
is changing data. I then write the value (via a hidden text box) to a
record-level field.

_______________________________________________________________________________________


Option Explicit

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

Dim iStringLength As Long, i As Long
Dim sString As String

sString = String(255, 0)

iStringLength = Len(sString)
sString = Space$(iStringLength)

If WinAPI_GetUserName(sString, iStringLength) Then
i = InStr(sString, Chr(0))
If i Then
sString = Left(sString, i - 1)
End If
NetworkUserName = Trim(Left$(sString, iStringLength))
Else
NetworkUserName = "Unknown"
End If

End Function

.



Relevant Pages

  • How do I limit the text in a bookmark
    ... Dim sString As String ... Dim iCount As Integer ... just that amount of characters. ...
    (microsoft.public.word.vba.general)
  • Re: Heres a "CASE" statement with strings... sorta.
    ... constructing the constant list and string list. ... 'First' = sString then begin doThis; exit;end;if ... to synchronize two or three lists for every change in the ...
    (alt.comp.lang.borland-delphi)
  • Re: =?ISO-8859-15?Q?Verschl=FCsseln_von_Daten?=
    ... Dein Code ist leider etwas undurchsichtig... ... As String = "") As Byte ... Dim sString As String = prv_key & sZusVersch ... Möglichkeit die Zeichenfolge zunächst mittels SHA256 zu kodieren ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: Very Confused On IIF
    ... > Public Sub Main ... > Private Function BracketsRemove(ByVal sString As String) As String ...
    (microsoft.public.vb.general.discussion)