By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,476 Members | 1,376 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,476 IT Pros & Developers. It's quick & easy.

Changing tracked user names to something more comprehensible

LeighW
P: 73
Hi all,

I'm tracking any changes made to records within the database which includes user name and storing it within an archive table (tbl_Archive)

To track the user name I'm using code I managed to find on this site within a form's module which works a treat and is shown below:

Expand|Select|Wrap|Line Numbers
  1. Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
  2. "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  3.  
  4. Function fOSUserName() As String
  5. ' Returns the login name for Adminstrator use
  6. Dim lngLen As Long, lngX As Long
  7. Dim strUserName As String
  8. strUserName = String$(254, 0)
  9. lngLen = 255
  10. lngX = apiGetUserName(strUserName, lngLen)
  11. If (lngX > 0) Then
  12. fOSUserName = Left$(strUserName, lngLen - 1)
  13. Else
  14. fOSUserName = vbNullString
  15. End If
  16. End Function
What I'd also like to be able to do is change the names given (which as it's a company computer happens to be an incomprehensible set of alphanumerics) to the users actual name so it's easier to understand who made the edit.

As this is going to be a private database with (at present) only a handful of users and the log-on name never changes, I'm guessing there must be a way of changing the names through a module or something.

I tried to create my own like this:

Expand|Select|Wrap|Line Numbers
  1. Public Function UserNames()
  2. LK039384 = "Leigh Woodcock"
  3. End Function
  4.  
And then placed "UserNames" after the code above but it still came up with the jargon rather than my actual name.

Any help would be much appreciated.

Leigh
Oct 3 '12 #1

✓ answered by Rabbit

You should create a user table. Then you can join your archive table to that on the user id to get the user's name. You won't have to edit your code every time a user is added or changed.

Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,315
You should create a user table. Then you can join your archive table to that on the user id to get the user's name. You won't have to edit your code every time a user is added or changed.
Oct 3 '12 #2

LeighW
P: 73
Of course! I don't know why I didn't think of that. My minds been too wrapped in VBA lately. That way it will be easy to introduce new names without getting into VBA.

Thanks for the help Rabbit
Oct 4 '12 #3

Rabbit
Expert Mod 10K+
P: 12,315
Sure thing. Good luck with your project.
Oct 4 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.