User ID in Access Table

  • Thread starter Thread starter TotallyConfused
  • Start date Start date
T

TotallyConfused

How can I incorporate the user's id into the main table of the database?
Thank you.
 
For what purpose? What are you trying to accomplish?

Create a table userid and password to secure something? Track record entry
by userid? etc....

Give us some meat on the bone so that we can guide you properly!
 
TotallyConfused said:
How can I incorporate the user's id into the main table of the database?
Thank you.

If you've invoked ULS then use the CurrnetUser function, else this code will
return the network logon ID.

Keith.
www.keithwilby.com

Option Compare Database
Option Explicit

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

' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
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
 
Thank you for responding. Sorry I wasn't more specific. Yes I do want the
login ID. Thank you. What I want to accomplish is at the end of a week user
needs to extract table and out put to Excel. I have a macro that
accomplishes this. But I want the copy of the table to include the user id
(which could be anyone of several indvidiuals that is why I need the user
id). Can I call this function to fill a field User Id in the table running
the macro? If so how? Thank you. Or is there a better way to do this?
 
TotallyConfused said:
I want the copy of the table to include the user id
(which could be anyone of several indvidiuals that is why I need the user
id). Can I call this function to fill a field User Id in the table
running
the macro? If so how? Thank you. Or is there a better way to do this?

Base a query on the table and include the function "fOSUserName" as a
calculated field in the query. Have the macro output the query instead of
the table.

Keith.
 
Back
Top