Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2006, 07:21 AM
Registered User
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default want to retreive current user name in windows

hi all,
i hope to find solution for my problem.

I want to retreive current user name in windows by VBA.

For example if I have textbox and bottun in a form.
I want if I click the bottun, the user name for windows will be displayed in the textbox.

Please help.
 
Old November 28th, 2006, 08:26 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to leehambly
Default

Hi,

Use Environ$("Username")... this should give the Username, but may also return a little bit of extra text, ie: USERNAME=xxxx instead of just xxxx, so you will have to test it out on your environment, either way with a function set up to handle the extra text you should be flying fairly quickly.

ie:

if left(environ$("USERNAME"),9) = "USERNAME=" then
 right(environ$("USERNAME"), len(environ$("USERNAME")-9)
else
 environ$("USERNAME")
end if

Hope it helps.

Lee
 
Old November 29th, 2006, 01:46 AM
Registered User
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very very much.
That's it






Similar Threads
Thread Thread Starter Forum Replies Last Post
How Can I Get the Name of the Current User? BrianWren Beginning VB 6 1 March 27th, 2007 12:28 PM
How Can I Get the Name of the Current User? BrianWren Pro VB 6 0 March 27th, 2007 11:42 AM
How can I retreive user role from sql server 2005? MAKO C# 0 July 7th, 2006 08:13 AM
Current user type dotnetprogrammer VS.NET 2002/2003 0 February 1st, 2005 07:20 AM
current user schockp Oracle 2 November 12th, 2003 06:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.