Logon

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

Guest

Hi!!

I try to find my username
i logon to a server with a name
but on my Pc i am "Admin" so if i use
currentusername i get "admin" and not my name i
use to logon to the server, is there a way to grab the username??

Best regards alvin
 
Hi Alvin
The easiest way is to check the environment variable Username;

mUserName = VBA.Interaction.Environ("USERNAME")
msgbox mUserName

Greetings
H
 
I assume you are talking about CurrentUser in Microsoft Access???

If you don't use Access Security, the CurrentUser Method _always_ returns
"Admin" (note that this is Access user "Admin" which has nothing to do with
your local PC "Admin"). The reason is that without Access security, Access
users will use the default user which is "Admin".

If you are trying to get your Windows network LogIn, try The Access Web:

http://www.mvps.org/access/api/api0008.htm
 
I haven't done VBA/VB in a while, but try this

in the form declarartions or module, use this line

Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As String, nSize As Long) As Long

Then somewhere in your program, here are the lines that should work

Dim sTest As String * 128
GetUserName sTest, Len(sTest)
MsgBox sTest

Hope that helps

Steve
 
Thanks I try it

Alvin


"Joe Smith" skrev:
I haven't done VBA/VB in a while, but try this

in the form declarartions or module, use this line

Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As String, nSize As Long) As Long

Then somewhere in your program, here are the lines that should work

Dim sTest As String * 128
GetUserName sTest, Len(sTest)
MsgBox sTest

Hope that helps

Steve
 
Back
Top