Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grab current users into textbox default value display 1

Status
Not open for further replies.

d1004

Programmer
May 9, 2002
78
0
0
US
If current user ID log into the network, I want to have the capability of putting that ID into my current user txt box.
Is there a way to do that. I know in DOS, you grab that by
using %username%
Thank you,
-D1004
 
Some years back I found this and kept it for later use, leter has not come yet :), so I have not tryed it but here it is:


Private Declare Function getusername Lib "advapi32" Alias "GetUserNameA"
(ByVal buffer As String, buffersize As Long) As Long
------------------------------------------------------------------------
Function getuser() As String
Dim username As String * 255
Dim namesize As Long
Dim errno As Long
namesize = Len(username)
errno = getusername(username, namesize)
getuser = Left(username, namesize - 1)

End Function
 
This is a really stupid question, but can I put that function inside my Private Sub UserID_Enter()
Thank you!
 
You could also use Environ("username")
 
I tried the environ("username"), and it works for Window 2000 OS, but it wouldn't let
me for Window 95. Is there any other method?
Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top