Results 1 to 10 of 10
  1. #1
    Desstro's Avatar
    Desstro is offline Competent Performer
    Windows XP Access 2010 (version 14.0)
    Join Date
    May 2010
    Posts
    185

    Question =GetUser() Function


    I read somewhere in this forum about an =GetUser function and I can't remember where. Could someone please direct me to some advice on this function and possibly some examples on any VBA coding?

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    what user do you want to get? the windows user name? if that's what you're looking for, one way to get it is here: http://www.ajenterprisesonline.com/_...?fname=GetUser

    a simpler way of doing it is to use the environ() function. either of these should be fine:
    Code:
    =environ(39)
    
    =environ("username")

  3. #3
    Desstro's Avatar
    Desstro is offline Competent Performer
    Windows XP Access 2010 (version 14.0)
    Join Date
    May 2010
    Posts
    185
    Thanks, could you briefly explain the environ function to me? And where shold the code go? I want to be able to track who did what to what file kind of thing.

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    who did what to what file? what do you mean? maybe a timestamp is what you need.

    the environ() function I don't know much about, in depth, but in general it can return some useful information about the local computer's current environment. Hence, the function name.

    There are 42 environment variables, some useful and some not. If you want to find out what they do, write a loop in vba code and print them out to the immediate window. The results I think will all list equalities. Left side = variable...right side = value

    The indexes are 1-42

  5. #5
    Desstro's Avatar
    Desstro is offline Competent Performer
    Windows XP Access 2010 (version 14.0)
    Join Date
    May 2010
    Posts
    185
    Im mostly just curious about the function.

    What i remember reading in the forum was someone who wanted to keep track of what user deleted a file. Kind of like a big brother function and I could see how that would come in handy around here as everyone has a work alternate that is at work when they are not, and the finger pointing is easy because the other person wouldn't be here to deny it.

    If there was a way to run a report showing who was the last to manipulate data on a specific record and they knew it was possible for the admin to run a report I might be able to put a stop to the old blame game.

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by Desstro View Post
    If there was a way to run a report showing who was the last to manipulate data on a specific record and they knew it was possible for the admin to run a report I might be able to put a stop to the old blame game.
    this is exactly why people use timestamps. use a form's DIRTY event and a table log and you can solve this in a tick!

  7. #7
    Desstro's Avatar
    Desstro is offline Competent Performer
    Windows XP Access 2010 (version 14.0)
    Join Date
    May 2010
    Posts
    185
    Would you mind showing me an example or point me in the direction of where some literature examples might be?

    Like I said still learning about Access and code, just started learning earlier this year.

    Examples really help me in the learning process.

  8. #8
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    google "ms access audit trail"

    that'll bring up allen browne's article on it, and it also brings up a KB article from ms about it...which I didn't know even existed.

  9. #9
    Desstro's Avatar
    Desstro is offline Competent Performer
    Windows XP Access 2010 (version 14.0)
    Join Date
    May 2010
    Posts
    185
    Sweet! Thanks again, I will mark this thread as solved since I was just seeking info. If I decide to implement this function in my DB and have any other questions or issues I will create another post.

  10. #10
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    The getuser function I posted in the code repository:

    https://www.accessforums.net/code-re...thod-7675.html

    This will return the user loginID securely (not hackable - ie. cannot be mimicked by a user) which can be done via other methods.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. GetUser method
    By pkstormy in forum Code Repository
    Replies: 7
    Last Post: 11-22-2012, 06:00 PM
  2. Need help with IIF function
    By RazMan in forum Access
    Replies: 4
    Last Post: 10-28-2010, 12:07 PM
  3. if function
    By lolo in forum Queries
    Replies: 1
    Last Post: 08-01-2010, 11:38 PM
  4. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 AM
  5. Avg Function
    By hiker8117 in forum Access
    Replies: 3
    Last Post: 04-23-2009, 11:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums