Hi,
Hope everyone is fine. Please note that I would like to add a field on my table that contains the last updated by and the last updated date.
As per the internet research that I did, I had added to my table the fields [Last updated Date] and [Last updated by].
Then on the form that I have on the text boxes of each of these fields I have added the following on the "Before Update" event:
For the last updated date:
And for the last updated by I found a function on internet that I had added to a module:
And then I have written on the line of "Before Update event" "fOSUserName()"
When I change the information on a column for a record these fields are not updated, they are on blank, do you have any idea why?
By the way I am displaying the information of the table as a split form and reviewing and working on the data as a spreadsheet view.
Do you know why this is not working? Thanks!
Hope everyone is fine. Please note that I would like to add a field on my table that contains the last updated by and the last updated date.
As per the internet research that I did, I had added to my table the fields [Last updated Date] and [Last updated by].
Then on the form that I have on the text boxes of each of these fields I have added the following on the "Before Update" event:
For the last updated date:
Me![Last Updated Date].Value = Now()
And for the last updated by I found a function on internet that I had added to a module:
Option Compare Database
Option Explicit
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
And then I have written on the line of "Before Update event" "fOSUserName()"
When I change the information on a column for a record these fields are not updated, they are on blank, do you have any idea why?
By the way I am displaying the information of the table as a split form and reviewing and working on the data as a spreadsheet view.
Do you know why this is not working? Thanks!