Logon

A

Alvin Hansen

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
 
H

HJD

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

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

Greetings
H
 
V

Van T. Dinh

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
 
J

Joe Smith

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
 
A

Alvin Hansen

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
 

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