5 replies
by m.r.chambers
Try having a look at this code. It finds the
user's name and displays it in a simple form,
but you may be able to adapt it for your
purposes. BTW, this works for win 95 but I
don't know about NT. (I didn't write this, it
was sent to me by someone a fair while ago)
----
Option Compare Database
Option Explicit
Public dbs As 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 String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName,
lngLen - 1)
Else
fOSUserName = ""
End If
End Function
Function startup()
Dim strWhoAmI As String
'Get username from above function
strWhoAmI = fOSUserName
'Display username
MsgBox "The Current User Name is:" & vbCrLf &
strWhoAmI, vbInformation
End Function
----
M.R.Chambers
by parier
by donq
=CurrentUser()
Set a text field to Current User in the After Update Event
Private Sub coaPK_AfterUpdate()
' SET THE AUTOMATED UPDATE VALUE TO THE CURRENT CLOCK TIME
' EVERY TIME THIS FIELD VALUE IS CHANGED.
coaUpd = Now()
' AUTOMATICALLY SET THE LOGGED-ON USER NAME TO Luid.
coaLuid = CurrentUser()
End Sub
by parier
by parier
This discussion is closed to new replies.
Trending Software posts
Sort by Trending