Joeclueless
Technical User
Hi,
please refer to:
thread700-448341
I started this thread in the Access tables and relationships forum, thinking that the default value of a field could return the username to the field. Then a respondant informed me that I should use a module to accomplish this.
KenReay (Programmer) offered me this code:
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
I am trying to use this code as a module. The way I am trying to accomplish this is by creating a new module, pasting the code into it, then save the module as Module1. Then in the form that the table is the record source, I am putting in the before update event of the form:
Me!User = fOSUserName()
Now, when I open the form the field that the username should appear in is blank. When I type in something and try to leave the form, the error:
UserTracker! can't find the Macro 'Me!User=fOSUserName().' etc...etc...
So, how can I make this work?? Any ideas are appreciated.
Thanks again!
Joe
please refer to:
thread700-448341
I started this thread in the Access tables and relationships forum, thinking that the default value of a field could return the username to the field. Then a respondant informed me that I should use a module to accomplish this.
KenReay (Programmer) offered me this code:
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
I am trying to use this code as a module. The way I am trying to accomplish this is by creating a new module, pasting the code into it, then save the module as Module1. Then in the form that the table is the record source, I am putting in the before update event of the form:
Me!User = fOSUserName()
Now, when I open the form the field that the username should appear in is blank. When I type in something and try to leave the form, the error:
UserTracker! can't find the Macro 'Me!User=fOSUserName().' etc...etc...
So, how can I make this work?? Any ideas are appreciated.
Thanks again!
Joe