Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2007
    Posts
    2

    Question Unanswered: Getting User Info in VBA

    Hi
    I'm building an Access db on a LAN and want to keep a log of certain actions users perform. How do I get a USERNAME from VBA?

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Access isn't a server product, so I moved this post into the correct forum.

    In answer to your question, take a look at the GetUserName API
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Also, if you're talking about the user logged in via Access security, use CurrentUser(). If not, an alternative to the API is the Environ() function.
    Paul

  4. #4
    Join Date
    Mar 2007
    Posts
    1
    Use this code to retrieve the username via VBA in Access

    Dim theUserName as String
    theUserName = Environ("USERNAME")

    Cheers, Daniel
    http://office.webforums.nl

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Oh no
    Here we go again. Anyone got a link to the last two page discussion we had about this? I reckon it should go in the FAQ.....

    IMO - don't use environ. Use the API.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Here we are (it was actually four pages):
    http://www.dbforums.com/showthread.php?t=1613951

    Teddy - if you read this is it an FAQ candidate?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    Perhaps it should be added to the thread:

    1) A Power User can change Environmental Variables outright in "My Computer" properties - entirely insecure.

    2) I didn't peak at the API code posted; I have a set of functions that will cope with earlier versions of windows (Pre "NT" based OS store the ID of the logged user in a different place in the registry) based on a single function call if interested.

    3) I wholeheartedly agree with making the authentication behind the scenes - the less a potential hacker knows about, the better.

    4) OS Login based authentication is only marginally effective if is it not paired with a timeout function.

    tc

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I deliberately didn't post in this thread because I didn't want to bring back the old Environ arguement

    If security is a real concern (you're wanting an audit log, so I assume it is) then use the API call.

    OR create a secure login (or use access built in security) and store the login information.
    George
    Home | Blog

Posting Permissions

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