X
xavier
After many tries I managed to get the function of
retieving user name & computer name to work using the
following function.
----------------------------------------------------
Public Function atCNames(UOrC As Integer) As String
'**************************************************
'Purpose: Returns the User LogOn Name or ComputerName
'Accepts: UorC; 1=User, anything else = computer
'Returns: The Windows Networking name of the user or
computer
'**************************************************
On Error Resume Next
Dim NBuffer As String
Dim Buffsize As Long
Dim Wok As Long
Buffsize = 256
NBuffer = Space$(Buffsize)
If UOrC = 1 Then
Wok = api_GetUserName(NBuffer, Buffsize)
atCNames = Left$(NBuffer, InStr(NBuffer, Chr(0)) - 1)
Else
Wok = api_GetComputerName(NBuffer, Buffsize)
atCNames = Left$(NBuffer, InStr(NBuffer, Chr(0)) - 1)
End If
End Function
--------------------------------------------------------
with the above and using an unbound text box where
the control source is
=" " & atCNames(1) (to retrieve user name)
or
=" " & atCNames(2) (to retrieve computer name)
--------------------------------------------------------
all this works fine but I need to save these values
in a table whenever they try to add something.
I tried using the following in the beforeupdate of the
form but got no result
ME!user=" " & atCNames(1)
where (user) is the name of a field in my table but it
does nothing, if I try doing it under ongotfocus I still
get nothing.
any help is greatly appreciated
Xavier
retieving user name & computer name to work using the
following function.
----------------------------------------------------
Public Function atCNames(UOrC As Integer) As String
'**************************************************
'Purpose: Returns the User LogOn Name or ComputerName
'Accepts: UorC; 1=User, anything else = computer
'Returns: The Windows Networking name of the user or
computer
'**************************************************
On Error Resume Next
Dim NBuffer As String
Dim Buffsize As Long
Dim Wok As Long
Buffsize = 256
NBuffer = Space$(Buffsize)
If UOrC = 1 Then
Wok = api_GetUserName(NBuffer, Buffsize)
atCNames = Left$(NBuffer, InStr(NBuffer, Chr(0)) - 1)
Else
Wok = api_GetComputerName(NBuffer, Buffsize)
atCNames = Left$(NBuffer, InStr(NBuffer, Chr(0)) - 1)
End If
End Function
--------------------------------------------------------
with the above and using an unbound text box where
the control source is
=" " & atCNames(1) (to retrieve user name)
or
=" " & atCNames(2) (to retrieve computer name)
--------------------------------------------------------
all this works fine but I need to save these values
in a table whenever they try to add something.
I tried using the following in the beforeupdate of the
form but got no result
ME!user=" " & atCNames(1)
where (user) is the name of a field in my table but it
does nothing, if I try doing it under ongotfocus I still
get nothing.
any help is greatly appreciated
Xavier