Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Location
    Belgium
    Posts
    42

    Post Unanswered: How to get the NT useraccount in VBA?

    Hi,

    Is it possible to get the NT useraccount in VBA through code?
    I've tried 'CurrentUser' but that returns the Access-account...
    It would score a very good point to my boss if it is possible to link the NT useraccout with access ;-)

    Thanks,

    Koen

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: How to get the NT useraccount in VBA?

    Originally posted by MrData
    Hi,

    Is it possible to get the NT useraccount in VBA through code?
    I've tried 'CurrentUser' but that returns the Access-account...
    It would score a very good point to my boss if it is possible to link the NT useraccout with access ;-)

    Thanks,

    Koen
    Through API
    Here it is:

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

    Function fOSUserName() As String
    ' Returns the network login name
    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

  3. #3
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465

    Re: How to get the NT useraccount in VBA?

    Originally posted by MrData
    Hi,

    Is it possible to get the NT useraccount in VBA through code?
    I've tried 'CurrentUser' but that returns the Access-account...
    It would score a very good point to my boss if it is possible to link the NT useraccout with access ;-)

    Thanks,

    Koen
    Do you want to how many user are login in your MDB base....
    Saludos
    Norberto

  4. #4
    Join Date
    Dec 2003
    Location
    Belgium
    Posts
    42

    Re: How to get the NT useraccount in VBA?

    Thanks a lot! Already scored that point :One for me, boss: zero :-)

    Does this code also works for WIN 98, I can't test it here right now...

    Waiting to score another point :-)

    Greetz

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: How to get the NT useraccount in VBA?

    Originally posted by MrData
    Thanks a lot! Already scored that point :One for me, boss: zero :-)

    Does this code also works for WIN 98, I can't test it here right now...

    Waiting to score another point :-)

    Greetz
    I think this code should run under Windows 98 too? Did you test it under NT or under which system?

  6. #6
    Join Date
    Dec 2003
    Location
    Belgium
    Posts
    42

    Talking Re: How to get the NT useraccount in VBA?

    Originally posted by hammbakka
    I think this code should run under Windows 98 too? Did you test it under NT or under which system?
    I've just had some spare time so tested the code on WIN2K, XP and WIN98... and it WORKS!

    Thanks for your help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •