windows logon name

  • Thread starter Thread starter RonB
  • Start date Start date
R

RonB

Guest
I have some code via developer to get user name from
windows
Function FindUserName() As String
' This procedure uses the Win32API function GetUserName
' to return the name of the user currently logged on to
' this machine. The Declare statement for the API function
' is located in the Declarations section of this module.

Dim strBuffer As String
Dim lngSize As Long

strBuffer = String(100, " ")
lngSize = Len(strBuffer)

If GetUserName(strBuffer, lngSize) = 1 Then
FindUserName = Left(strBuffer, lngSize)
Else
FindUserName = "Name not available"
End If
End Function

can anyone give me a example of the 'Declaration statement' as mentioned above
 
Please don't post the same question under various fora. I already answered you under the Form forum
 
Ok, I changed the module name to 'windowsusername' and then I changed my text box control source to =windowsusername().

However, I still only get '#Name' returned in my text box.


Also, should the code in the module have a line through it after this line:

Code:
 "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

When I paste it in it automatically puts this break between sections of code.
 
Ok, I changed the module name to 'windowsusername' and then I changed my text box control source to =windowsusername().

However, I still only get '#Name' returned in my text box.


Also, should the code in the module have a line through it after this line:

Code:
 "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

When I paste it in it automatically puts this break between sections of code.
Posting in a 7 year old post is not recommended. Just start a new one. But anyway, here's essentially the same thing:
http://www.mvps.org/access/api/api0008.htm
 
Ooops, that was accidental. I thought I had my tab with my post form earlier today but I must have been on my tab I was using to search the forum. Hence the reply in the wrong place.

It should have gone here...

http://www.access-programmers.co.uk/forums/showthread.php?t=163838


That was the code I used, but cannot get to work. See above.

(I'll paste my earlier response into teh correct thread too)
 
Ooops, that was accidental. I thought I had my tab with my post form earlier today but I must have been on my tab I was using to search the forum. Hence the reply in the wrong place.

It should have gone here...

http://www.access-programmers.co.uk/forums/showthread.php?t=163838


That was the code I used, but cannot get to work. See above.

(I'll paste my earlier response into teh correct thread too)

I posted the answer to your corrected thread
http://www.access-programmers.co.uk/forums/showthread.php?t=163838
 

Users who are viewing this thread

Back
Top Bottom