users

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
 
D

Duane Hookom

Can you provide some information about your text box:

Name:
Control Source:
Default Value:
 
G

Guest

text box

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

Thanks for looking into my query
 
D

Douglas J Steele

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.
 
G

Guest

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
 
G

Guest

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

Larry Linson

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top