N
Nick hfrupn
I have a table, tbSamples, with a field UserID. when a new recorded is added
I would like to default the User ID of the person loged on, adding the record.
I have tried using; =CurrentUser() , this only returned Admin regardless of
who was logged on.
It was suggested that I try this web site;
http://www.mvps.org/access/api/api0008.htm
I created a module, modUserID and pasted in the code from below.
This is where I come un-stuck. How do I activate this module to default the
User ID into the field?
I am using Windows and Access 2000.
Any help appreciated.
Nick
'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
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
'******************** Code End **************************
I would like to default the User ID of the person loged on, adding the record.
I have tried using; =CurrentUser() , this only returned Admin regardless of
who was logged on.
It was suggested that I try this web site;
http://www.mvps.org/access/api/api0008.htm
I created a module, modUserID and pasted in the code from below.
This is where I come un-stuck. How do I activate this module to default the
User ID into the field?
I am using Windows and Access 2000.
Any help appreciated.
Nick
'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
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
'******************** Code End **************************