Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 May 23rd, 2006, 05:05 PM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default user logged

Hy there!
Could someone help me here please.
Is there any code to use in Access 2003 where I can get the username of the user Logged?
I've got one for Access 97 but now my boss is instaling Access 2003 and after tested it wasnt work. Can someone help me Please. Thanks

Jony Bravo

 
Old May 24th, 2006, 07:50 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

What code do you have for 97?

mmcdonal
 
Old May 24th, 2006, 03:59 PM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've got the following code:

Option Compare Database
Option Explicit
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function FOSUsername() As String
    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 = vbNullString
        End If
End Function


Thanks to help me

 
Old May 24th, 2006, 04:06 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Here is the code that I use in 2003. I probably couldn't explain how it works, but it does :-)

Code:
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long


Public Function localUserName() As String
Dim m_myBuf As String * 25
Dim m_Val As Long, UserName As String

m_Val = GetUserName(m_myBuf, 25)
localUserName = Left(m_myBuf, InStr(m_myBuf, Chr(0)) - 1)
End Function
HTH

Mike

Mike
EchoVue.com
 
Old May 24th, 2006, 04:29 PM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks echovue

This work perfect.

:)

 
Old November 27th, 2006, 07:22 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to anukagni Send a message via Yahoo to anukagni
Default

Hi i had taken the theard by searching i want to get the user logged details, i think this is the way to do in DB is any one explain me clearly about this from the base...



Learn as you can..
------------------------
pap...
 
Old November 27th, 2006, 09:14 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

sU = (Environ$("Username"))

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I check whether a user is logged in or out rittwick PHP Databases 1 August 19th, 2007 04:47 PM
to keep the user logged in until he sign out sarah lee ASP.NET 1.0 and 1.1 Basics 14 December 14th, 2006 11:55 AM
Username of logged in user spardoe BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 August 18th, 2006 01:13 AM
Getting the name of the logged on user Grahame2003 C# 2 March 4th, 2004 04:48 AM





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