PC Review


Reply
Thread Tools Rate Thread

How to Capture the Value of "User Name" (or Initials) in Access 2007

 
 
Douglas J. Steele
Guest
Posts: n/a
 
      3rd Apr 2009
You can get their network ID using the code in
http://www.mvps.org/access/api/api0008.htm at "The Access Web"

If the administrator has filled in the name when creating the ID, you can
use the code in http://www.mvps.org/access/api/api0066.htm

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"news.microsoft.com" <(E-Mail Removed)> wrote in message
news:ebX$(E-Mail Removed)...
> What VBA code do I use to determine the "User Name" or "Initials" of the
> user?
>



 
Reply With Quote
 
 
 
 
PJFry
Guest
Posts: n/a
 
      3rd Apr 2009
Do you mean the person logged into the workstation? If so, create a new
module and paste this in:

'Used for grabbing the network name
Private Declare Function apiGetUserName _
Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As
Long
'Grabs the users network ID
Function fOSUserName() As String
On Error GoTo fOSUserName_Err

Dim lngLen As Long, lngX As Long
Dim strUserName As String

strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)

If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If


fOSUserName_Exit:
Exit Function

fOSUserName_Err:
MsgBox Error$
Resume fOSUserName_Exit
End Function

Any time you need to record the network name, use the fOSUserName().

Post back if you need something different.
--
Regards,

PJ
Please rate this post using the vote buttons if it was helpful.



"news.microsoft.com" wrote:

> What VBA code do I use to determine the "User Name" or "Initials" of the
> user?
>
>
>

 
Reply With Quote
 
 
 
 
news.microsoft.com
Guest
Posts: n/a
 
      3rd Apr 2009
What VBA code do I use to determine the "User Name" or "Initials" of the
user?


 
Reply With Quote
 
news.microsoft.com
Guest
Posts: n/a
 
      3rd Apr 2009
Thanks, but. . . .

In retrospect, I was not clear: I am asking for the "User Name" and
"Initials" that are in Access 2007 itself, not the network name.

This is under Access Options, "personalize your copy of Microsoft Office".

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote in message
news:(E-Mail Removed)...
> You can get their network ID using the code in
> http://www.mvps.org/access/api/api0008.htm at "The Access Web"
>
> If the administrator has filled in the name when creating the ID, you can
> use the code in http://www.mvps.org/access/api/api0066.htm
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "news.microsoft.com" <(E-Mail Removed)> wrote in message
> news:ebX$(E-Mail Removed)...
>> What VBA code do I use to determine the "User Name" or "Initials" of the
>> user?
>>

>
>



 
Reply With Quote
 
news.microsoft.com
Guest
Posts: n/a
 
      4th Apr 2009
This works but returns "Administrator" (I am using WinXP and Access 2007).
This is not particularly helpful on my network where all of the computers
have administrator.

How do I locate a more useful name (such as the "User Name" and "Initials"
inside of Access)?

"PJFry" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Do you mean the person logged into the workstation? If so, create a new
> module and paste this in:
>
> 'Used for grabbing the network name
> Private Declare Function apiGetUserName _
> Lib "advapi32.dll" Alias "GetUserNameA" _
> (ByVal lpBuffer As String, nSize As Long) As
> Long
> 'Grabs the users network ID
> Function fOSUserName() As String
> On Error GoTo fOSUserName_Err
>
> Dim lngLen As Long, lngX As Long
> Dim strUserName As String
>
> strUserName = String$(254, 0)
> lngLen = 255
> lngX = apiGetUserName(strUserName, lngLen)
>
> If lngX <> 0 Then
> fOSUserName = Left$(strUserName, lngLen - 1)
> Else
> fOSUserName = ""
> End If
>
>
> fOSUserName_Exit:
> Exit Function
>
> fOSUserName_Err:
> MsgBox Error$
> Resume fOSUserName_Exit
> End Function
>
> Any time you need to record the network name, use the fOSUserName().
>
> Post back if you need something different.
> --
> Regards,
>
> PJ
> Please rate this post using the vote buttons if it was helpful.
>
>
>
> "news.microsoft.com" wrote:
>
>> What VBA code do I use to determine the "User Name" or "Initials" of the
>> user?
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word merge from Access 2007 to Word 2007 brings over PK value and not text value. Kellyzeroes General Software 0 13th Jul 2011 07:50 PM
MS Access 2007: Capture parameter value and pass it to a form's field OLG General Software 0 5th Apr 2011 02:25 PM
VBA IIf(myCell.Value = Array(myCell2(1).Value, myCell2(2).Value,myCell2(3).Value,myCell2(4).Value) ,"OK","No Match) EagleOne@discussions.microsoft.com Microsoft Excel Programming 2 24th Apr 2009 11:25 PM
New capture card still pulls old capture card drivers John Windows XP Video 0 15th Jan 2004 04:14 AM
Windows XP video capture/WDM Video For Windows Capture Driver (Win32 rtbulkley Windows XP Video 0 5th Aug 2003 02:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:38 PM.