Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to extract logged on user's ID

Status
Not open for further replies.

jaxflorida

Technical User
Apr 16, 2002
27
0
0
US
I have set up my database so that each user has to log on as themselves. I want them to be able to "accept" a record as their own by clicking the "I accept" button which would put their userID in a field.

Does anyone know how to put the user ID from the log on screen into a field?

I would appreciate any help!

Thanks
 
This code was posted in another forum. I used it before I follwed the disipline of tracking sources of code. There is very little of my work here so I won't take credit, but it works great.

Code:
Public Function CNames() As String
'UserorComputer; 1=User, anything else = computer
Dim NBuffer As String
Dim Buffsize As Long
Dim wOK As Long
Dim Uname, Cname As String
Dim LAccess As Date

    Buffsize = 256
    NBuffer = Space$(Buffsize)
       
    'Gte the Username
    wOK = api_GetUserName(NBuffer, Buffsize)
     Uname = Trim$(NBuffer)
    
    'Reset all variables
    Buffsize = 256
    NBuffer = Space$(Buffsize)
    
    'Get the Computer Name
    wOK = api_GetComputerName(NBuffer, Buffsize)
    Cname = Trim$(NBuffer)
    LAccess = Now()
    
    CNames = Uname & "   " & Cname & "   Last Accessed at: " & Format(LAccess, "MM/DD/YYYY HH:NN")
End Function

This will get the computer ID as well. Just comment that part of the code and only return the portion you want.
 
Wow. That's a lot of code. Try this:
CurrentUser

That will return the username of the person logged on.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top