G
Gordon
On my form I have fields for "input by" and "updated by" which I want
to populate with the user's system network logon name. I am using a
function obtained from Dev Ashish' website:
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 = vbNullString
End If
End Function
I set the default value for "input by" to be =fOSUserName() and that
works fine but I can't get the "updated by" field on the form to work.
I have tried (in the beforeupdate event):
If Me.Dirty = True Then
Me!fldUpdatedBy = fOSUserName
Me!fldDateLastUpdated = Now()
End If
....but that doesn't work.
Can anyone help?
Gordon
to populate with the user's system network logon name. I am using a
function obtained from Dev Ashish' website:
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 = vbNullString
End If
End Function
I set the default value for "input by" to be =fOSUserName() and that
works fine but I can't get the "updated by" field on the form to work.
I have tried (in the beforeupdate event):
If Me.Dirty = True Then
Me!fldUpdatedBy = fOSUserName
Me!fldDateLastUpdated = Now()
End If
....but that doesn't work.
Can anyone help?
Gordon