users

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the below code, which was in a link, thanks for that gentleman who
gave it to me

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 made a module and inserted the above code in it, had a text box users in
the form and called it

though got lost here since the users name does not appear in the textbox user

please help
 
Can you provide some information about your text box:

Name:
Control Source:
Default Value:
 
text box

Name: users
Control Source:users
Default Value: (empty)

Thanks for looking into my query
 
How are you using that function? You've got the textbox bound to a field in
the table, so it's only going to show what's in the table.
 
well, ideally what I need is to capture the username of the specific system
in the field. Now there is 5 users in a network and instead users typing or
selecting from the list its proper to have the name displayed auto.

I had the below code in a module, need to know how to call this module from
the form

Thanks
 
I think I found the solution, I have to call from the field under Controld
sourece the below
=fOSUserName()
 
I think I found the solution, I have to
call from the field under Controld
sourece the below
=fOSUserName()

Yes, that's called a Calculated Control. Just be aware that the retrieved
user name will not be stored in your tables unless you take additional
action to store it there.

Larry Linson
 
U are right. the value keep changing as and when I keep changing the users.
how can I store the users value for a record permanent

plz advise

thanks
 
Back
Top