I use a function someone gave me to determine the Network username from the Windows Registry. This works on Win98 and Win2k.
Go to the Modules tab, click on New. Paste this in exactly as written:
code:
--------------------------------------------------------------------------------
Option Compare Database
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As StringstrUserName = String$(254, 0)lngLen = 255lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)Else
fOSUserName = ""
End If
End Function
--------------------------------------------------------------------------------
Now you can use fOSUserName() (or as a control source, for example, =fOSUserName() )to stand for your user's login name to the computer.
It doesn't matter what you name the module when you save it. Only the function name matters.
Col
ps - thanks to David R for this
[This message has been edited by ColinEssex (edited 05-14-2002).]