Title: Message
Cathy -
 
Add the following line near the top of your module.
 
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Lava

 

------------------------------------------------

Lava Boggavarapu

Lava Trading Inc.

95 Morton Street

New York, NY 10014

 

Tel 212.519.9371

Mobile 732.668.2935

www.lavatrading.com

-----Original Message-----
From: AccessDevelopers@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Cathy Jupp
Sent: Friday, January 06, 2006 8:45 AM
To: AccessDevelopers@yahoogroups.com
Subject: RE: [AccessDevelopers] getting the windows user name

I've just tried using the techniques described below, but I've had problems with both.  Whichever one I try to use, I get a compilation error message saying that the function is undefined - either GetUserName or wuGetUserName, depending on which of the below functions I try to use.  Clearly I'm doing something wrong, but can anyone tell me what, please?
Many thanks in advance.
Cathy
-----Original Message-----
From: AccessDevelopers@yahoogroups.com [mailto:[EMAIL PROTECTED]On Behalf Of Lava Boggavarapu
Sent: 12 December 2005 13:31
To: AccessDevelopers@yahoogroups.com
Subject: RE: [AccessDevelopers] getting the windows user name

Try

 

Public Function NetUser() As String

Dim sUName$

Dim lCnt As Long, lRet As Long

 

    NetUser = ""

    sUName = String$(255, 0)

    lCnt = 255

    lRet = GetUserName(sUName, lCnt)

    If lCnt > 0 Or lRet <> 0 Then

        NetUser = Left(sUName, lCnt - 1)

    End If

 

End Function

 

I got this from somewhere else.

 

Lava

 

------------------------------------------------

Lava Boggavarapu

Lava Trading Inc.

95 Morton Street

New York, NY 10014

 

Tel 212.519.9371

Mobile 732.668.2935

www.lavatrading.com

-----Original Message-----
From: AccessDevelopers@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of jezmo_codpiece
Sent: Monday, December 12, 2005 8:28 AM
To: AccessDevelopers@yahoogroups.com
Subject: [AccessDevelopers] getting the windows user name

 

I am trying to get the logged in windows user name to record the
last person to edit a record. I can do this OK using the following:


Function ap_GetUserName() As Variant

Dim strUserName As String
Dim lnglength As Long
Dim lngResult As Long

' set up the buffer
strUserName = String$(255, 0)
lnglength = 255
lngResult = wu_GetUserName(strUserName, lnglength)

ap_GetUserName = strUserName

End Function

But the string seems to be filled with non-usable characters after
the username, as when I try to paste this to a text box it tells me
the string is too long. Does anyone know how to easily get just the
user name without the garbage?
Many thanks in advance.




The information contained in this message and any attachments (the "Message") is intended for specific individual(s), and may be confidential or proprietary. If you are not the intended recipient, please notify the sender immediately, delete this Message and do not disclose. Messages are not secure or error free and can contain viruses and the sender is not liable for any of these occurrences. The sender reserves the right to monitor, record and retain Messages.

The information contained in this message and any attachments (the "Message") is intended for specific individual(s), and may be confidential or proprietary. If you are not the intended recipient, please notify the sender immediately, delete this Message and do not disclose. Messages are not secure or error free and can contain viruses and the sender is not liable for any of these occurrences. The sender reserves the right to monitor, record and retain Messages.






Please zip all files prior to uploading to Files section.




SPONSORED LINKS
Microsoft access developer Microsoft access help Microsoft access database
Microsoft access training Microsoft access training course Microsoft access programming


YAHOO! GROUPS LINKS




Reply via email to